Giter Club home page Giter Club logo

docpad-plugin-marked's Introduction

Marked Plugin for DocPad

Travis CI Build Status NPM version NPM downloads Dependency Status Dev Dependency Status
GitHub Sponsors donate button Patreon donate button Flattr donate button Liberapay donate button Buy Me A Coffee donate button Open Collective donate button crypto donate button PayPal donate button Wishlist browse button

Markdown rendering for DocPad, using Marked

Convention: .html.md|markdown

Configure

For information on customising your plugin configuration you can refer to the DocPad FAQ

Marked Options

You can customise the Marked options by using the markedOptions object. By default we use:

pedantic: false
gfm: true
sanitize: false
highlight: null

Install

Install this DocPad plugin by entering docpad install marked into your terminal.

History

Discover the release history by heading on over to the HISTORY.md file.

Contribute

Discover how you can contribute by heading on over to the CONTRIBUTING.md file.

Backers

Maintainers

These amazing people are maintaining this project:

Sponsors

No sponsors yet! Will you be the first?

GitHub Sponsors donate button Patreon donate button Flattr donate button Liberapay donate button Buy Me A Coffee donate button Open Collective donate button crypto donate button PayPal donate button Wishlist browse button

Contributors

These amazing people have contributed code to this project:

Discover how you can contribute by heading on over to the CONTRIBUTING.md file.

License

Unless stated otherwise all works are:

and licensed under:

docpad-plugin-marked's People

Contributors

balupton avatar daphne-d avatar delapouite avatar dependabot[bot] avatar kizu avatar robloach avatar varya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docpad-plugin-marked's Issues

Marked not converting line breaks to `<p>` tags or rendering HTML when fetched as collection in eco template

I am having issues with the Marked plugin not rendering line breaks as paragraph tags when content is fetched as a collection. I see the line breaks being added in Chrome dev tools.

I am also having issues with some HTML tags not being rendered, e.g. lists. Some tags (i.e. <i>) appear to render fine.

I've created a collection as so:

services: ->
  @getCollection('html').findAllLive(
      relativeOutDirPath: 'services'
      omitFromCollection: {$ne: true}
      [{weight:1}]
  )

In my Eco template, I am fetching the collection as so:

<% for service in @getCollection("services").findAll().toJSON(): %>

The following code will render some HTML (like <i> tags) but it will not convert \n to <p>:

<%- service.content %>

When it's rendered on its own page, it works perfectly. Am I creating the collection wrong or is this a bug?

I added some hacky JS for the meantime to fix the line breaks, and thankfully I don't need to use lists at this time, but it would be nice if the Marked plugin supported this out-of-the-box for fetching as collections as well.

For others who have the same problem, here's my quick fix for the paragraphs until the Marked plugin converts line breaks to paragraphs:

<p>
<% @serviceContent = service.content.replace(/\n/g, '</p><p>') %>
<%- @serviceContent %>
</p>

Thanks for your help!

Improve documentation

After inspecting the code, it seems there is an undocumented feature: markedRenderer. See this gist for more info. It would be nice to add that to README.md so people can know about this shortcut :).

Also, at first it wasn't clear to me that I had to put markedOptions in docpadConfig.plugins.marked. (I tried things like docpadConfig.plugins.markedOptions and docpadConfig.plugins.marked.[marked setting here]. This was probably due to me not interpreting correctly, but some extra clarity never hurts.

I suggest something like this snippet:

You can customise the Marked options by using the `markedOptions` object. Custom marked renderers can be added via `markedRenderer`, like so:
docpadConfig =
    plugins:
        marked:
            markedOptions:
                # customize Marked here... (see https://github.com/chjj/marked#options-1)
            markedRenderer:
                # custom renderer methods here...
                # same as passing a custom renderer instance to `docpadConfig.plugins.marked.markedOptions.renderer` (https://github.com/chjj/marked#renderer)
                # for accepted keys, refer: https://github.com/chjj/marked#block-level-renderer-methods and https://github.com/chjj/marked#inline-level-renderer-methods

Odd behaviour with marked renderer override

I'm trying to use the renderer option for marked: https://github.com/chjj/marked#renderer

I expects an instance with some methods, like from new marked.Renderer().

But the plugin errors somewhere in marked, it cannot find methods on the instance I set in the markedOptions.

I investigated and it looks like something is replacing my instance with another object? A model with has/get/set methods?

All options properties get passed but methods get removed.

Moderate severity security vulnerability detected in marked < 0.3.9

Hi dear Bevry team,

Github informed me by email this morning there is a moderate severity security vulnerability detected in marked < 0.3.9, in my website ...
But Docpad in this actual version (v6.79.4) require docpad-plugin-marked in ~2.4.0 ...
Maybe it's time for an update ?

thanks for your work !

Turn santisation off by default

Each day on IRC someone is experiencing issues with sanitisation. We should make this off by default, instead of on.

Any arguments against this change @chase ?

Support for rendering methods overrides

Since it’s already supported by Marked, it would be great to be able to override renderers right from Docpad’s config. It’s also partially supported by docpad-plugin-robotskirt. Something like this:

plugins: {
marked: {
  markedRenderer: {
    heading: function (text, level) {
      var escapedText = text.toLowerCase().replace(/[^\w]+/g, '-');
      return '<h' + level + '>' +
        text + ' <a name="' +
        escapedText +
        '" class="anchor" href="#' +
        escapedText +
        '"><span class="header-link"># </span></a></h' + level + '>';
    }
  }
},

Copied from StackOverflow question full of additional details.

There’s even a fork with all needed features applied, so it’s just a matter of checking if everything is correct and filing a pull request.

/cc @vladikoff @varya

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.