Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows to include an external file which can set the markdown settings #166

Closed
wants to merge 1 commit into from
Closed

Allows to include an external file which can set the markdown settings #166

wants to merge 1 commit into from

Conversation

butsjoh
Copy link

@butsjoh butsjoh commented Nov 28, 2014

Instead of providing the "marked" markdown settings through the apidoc binary i extended it with the ability to load an external file which allows to set the marked settings + extensions you want to the markdown parsing.

By doing:

apidoc --marked-config markdown_config.js

and have a file "markdown_config.js":

// Be including marked here we could overwrite the renderer really easy
var marked = require('apidoc/node_modules/marked');
var myRenderer = new marked.Renderer();

// A lot of the markdown rendering function can be altered this way
// eg: below we add target blank for each external link
myRenderer.link = function(href, title, text) {
  var external, newWindow, out;
  external = /^https?:\/\/.+$/.test(href);
  newWindow = external || title === 'newWindow';
  out = "<a href=\"" + href + "\"";
  if (newWindow) {
    out += ' target="_blank"';
  }
  if (title && title !== 'newWindow') {
    out += " title=\"" + title + "\"";
  }
  return out += ">" + text + "</a>";
};

// options can be set as wanted
module.exports = {
  gfm: true,
  tables: true,
  breaks: false,
  pedantic: false,
  sanitize: false,
  smartLists: false,
  silent: false,
  highlight: null,
  langPrefix: '',
  smartypants: false,
  headerPrefix: '',
  renderer: myRenderer,
  xhtml: false
};

Also sorry for the fuckup with the previous pr. I though the dev branch of you was the one to pull request against but i was wrong :)

@rottmann
Copy link
Member

Thank you, will be included in 0.9. release it today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants