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

Fix: TextRenerer.paragraph is not a function #1200

Closed
wants to merge 1 commit into from
Closed

Fix: TextRenerer.paragraph is not a function #1200

wants to merge 1 commit into from

Conversation

FlorianKoerner
Copy link

Description

The method paragraph is missing in the TextRenderer.

Result

TypeError: this.renderer.paragraph is not a function

What was attempted

marked('Test', {
    renderer: new marked.TextRenderer()
})

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.
  • If submitting new feature, it has been documented in the appropriate places.

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
Copy link
Member

UziTech commented Apr 4, 2018

I'm not sure that is the way it is supposed to be done.

Line 951 has a comment that reads:

// no need for block level renderers

@Feder1co5oave is there a reason block level renderers are not needed in TextRenderer?

@Feder1co5oave
Copy link
Contributor

For now, TextRenderer is only used to strip markdown formatting out of headings' text, in order to generate a clean ID. They contain only inline formatting. See #450.

The same thing should be done for images' alt text, according to commonmark. See 2e23540.

It was not meant to be used as a renderer to parse a whole document, although it could be made into one by implementing all block level renderers consistently. That way it could be used to turn markdown code into plain text. Implementing only the paragraph one is not enough.

@UziTech
Copy link
Member

UziTech commented Apr 4, 2018

@FlorianKoerner what was the purpose of setting the TextRenderer as the Renderer in marked?

@FlorianKoerner
Copy link
Author

Originally my intention was to parse only inline blocks. Meanwhile I know that the TextRenderer is the wrong tool for this.

Is there an easy way to render only inline blocks?

@joshbruce
Copy link
Member

See lines 856 to 858:

Renderer.prototype.paragraph = function(text) {
  return '<p>' + text + '</p>\n';
};

Is this what you were trying to access @FlorianKoerner and received a bad function call reference??

@joshbruce
Copy link
Member

Not that I can tell given the way the renderer is described at the moment. Having said that, it might make sense in the future. We have inline and block flavors of the lexer and parser...and almost the renderer.

@joshbruce
Copy link
Member

Tagging with #746 something to potentially introduce in 1.x or 2.x

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