镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

use default options in Renderer by default - #1203

Merged
styfle merged 1 commit into
markedjs:masterfrom
UziTech:UziTech-patch-1
Apr 5, 2018
Merged

styfle merged 1 commit into
markedjs:masterfrom
UziTech:UziTech-patch-1

Conversation

@UziTech

@UziTech UziTech commented Apr 4, 2018 •

Copy link
Copy Markdown
Member

Marked version: 0.3.19

Description

  • Sets the Renderer options to the default options by default

I'm not sure if there is a reason the Renderer options were set to an empty object instead of the default options. The Parser and Lexers are set to the default options already

function Renderer(options) {
  this.options = options || {};
  ...
function Lexer(options) {
  this.options = options || marked.defaults;
  ...
function InlineLexer(links, options) {
  this.options = options || marked.defaults;
  ...
function Parser(options) {
  this.options = options || marked.defaults;
  ...

Contributor

  • Test(s) exist to ensure functionality and minimize regression (if no tests added, list tests covering this PR); or,
  • no tests required for this PR.

Committer

In most cases, this should be a different person than the contributor.

  • Draft GitHub release notes have been updated.
  • CI is green (no forced merge required).
  • Merge PR

@UziTech
UziTech requested review from joshbruce and styfle April 4, 2018 19:36
@UziTech

UziTech commented Apr 4, 2018

Copy link
Copy Markdown
Member Author

@Feder1co5oave is there any reason Renderer options would be set to an empty object instead of the marked.defaults?

@styfle styfle left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's odd, maybe it was a miss?
This probably should use the defaults.

This is a breaking change for anyone using var r = new Renderer(), right?

@UziTech

UziTech commented Apr 4, 2018

Copy link
Copy Markdown
Member Author

Yes it would be a breaking change but I feel like it would be a fix. Right now that would be the same as the following:

var r = new Renderer({
  baseUrl: undefined,
  breaks: undefined,
  gfm: undefined,
  headerIds: undefined,
  headerPrefix: undefined,
  highlight: undefined,
  langPrefix: undefined,
  mangle: undefined,
  pedantic: undefined,
  renderer: undefined,
  sanitize: undefined,
  sanitizer: undefined,
  silent: undefined,
  smartLists: undefined,
  smartypants: undefined,
  tables: undefined,
  xhtml: undefined
});

which I don't think anyone would do willingly. So it would be more likely that anyone using the renderer would pass some options so this wouldn't break anything.

@joshbruce joshbruce left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would want to make sure our next release is 0.4.x due to the breaking change, but I think the options need some work anyway given what I've seen so far...might be a good place to start stabilizing things.

@joshbruce

Copy link
Copy Markdown
Member

ps. Just because this is a breaking change doesn't stop me from merging this. If neither @UziTech or @styfle are concerned committing to a 0.4.x as the next release, I would say we are good to go.

@UziTech

UziTech commented Apr 5, 2018

Copy link
Copy Markdown
Member Author

Ya I would say we should merge it as a bug fix and release when 0.4.x milestone is ready. I was looking through the blame and it looks like it was just missed when the renderer was created.

@joshbruce joshbruce mentioned this pull request Apr 5, 2018
4 tasks done
@styfle styfle added this to the 0.4.0 - No known defects milestone Apr 5, 2018
@styfle
styfle merged commit f4387f8 into markedjs:master Apr 5, 2018
@styfle

styfle commented Apr 5, 2018

Copy link
Copy Markdown
Member

Done

@Feder1co5oave

Copy link
Copy Markdown
Contributor

Because of lines 549 and 980. It gets overwritten anyways,

zhenalexfan pushed a commit to zhenalexfan/MarkdownHan that referenced this pull request Nov 8, 2021
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.

4 participants