-
Notifications
You must be signed in to change notification settings - Fork 100
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
Regression: since 0.28.0, marked filter does not render markdown in HTML blocks #310
Comments
I looked into the fact that the arguments for renderer.code = (code, language, escaped) => {
const trimmedCode = trimIndentation(code);
let renderedCode = marked.Renderer.prototype.code.call(renderer, trimmedCode, language, escaped); But it didn't help at all.
Doh, because the problematic markdown is not code... 🤦🏼♂️ |
OK, so this doesn't parse properly: <div class="alert alert-info">
**AngularJS Prefixes `$` and `$$`**:
To prevent accidental name collisions with your code,
AngularJS prefixes names of public objects with `$` and names of private objects with `$$`.
Please do not use the `$` or `$$` prefix in your code.
</div> But this does <div class="alert alert-info">
**AngularJS Prefixes `$` and `$$`**:
To prevent accidental name collisions with your code,
AngularJS prefixes names of public objects with `$` and names of private objects with `$$`.
Please do not use the `$` or `$$` prefix in your code.
</div> |
Failing test it("should render markdown links in divs", () => {
const html = renderMarkdown(
'<div>\n' +
' some text with an important [link](https://angularjs.org)\n' +
'</div>'
);
expect(html).toEqual(
'<div>\n' +
' some text with an important <a href="https://angularjs.org">link</a>\n' +
'</div>'
);
}); Passing test it("should render markdown links in divs with extra padding", () => {
const html = renderMarkdown(
'<div>\n\n' + // <-- this extra line feed is what makes it pass.
' some text with an important [link](https://angularjs.org)\n' +
'</div>'
);
expect(html).toEqual(
'<div>\n\n' +
'<p> some text with an important <a href="https://angularjs.org">link</a></p>\n' +
'</div>'
);
}); |
OK, this is a bug or breaking change by design in It works with |
I've opened markedjs/marked#2085 for this. It looks like this breaking change might be Working as Intended, but I hope that there is some way that I can monkey patch the parser/renderer to fix this w/o having to add a ton of blank line feeds throughout the old documentation. |
So the response from the
This kind of custom HTML block renderer could live in dgeni-packages, but it's not clear to me that it's viable or worth the effort. The Angular project has already moved on to That said, it's not ideal to leave the AngularJS and AngularJS Material projects on an old version of (╯°□°)╯︵ ┻━┻ |
- this adds 1 High severity advisory back in by pinning at `marked@0.3.6` - 301 vulnerabilities found - Severity: 189 Low | 28 Moderate | 80 High | 4 Critical - in reality, there are many serious security issues with this old version of `marked` - but our docs don't render with the newer versions due to angular/dgeni-packages#310 - another downside is that this forces `firebase-tools` to use an old, vulnerable version of marked for parsing console output
The CommonMark specification is what we should be following in our use of markdown (IMO). If the only problems with upgrading to the new version of dgeni-packages is that angular.js docs need to be updated to include blank lines to trigger the switch from HTML mode to markdown mode then that is the most appropriate fix. Note that remark (used in the Angular project) also conforms to this CommonMark specfiication. Closing as this is working as expected in dgeni-packages. |
I first hit this in angular/material#11881, which ended up with the project pinning the dependency to
0.27.5
and not being able to upgrade since then. At that time, early 2020, I was quite unfamiliar with Marked and how it was used in dgeni-packages. So I was hoping that someone else would report this and it would get fixed. Unfortunately, that hasn't happened.I have dug deeper recently in angular/angular.js#17141 and this seems to be related to 16ceb9c from PR #281, released in
0.28.0
.There is a breaking changes note:
renderMarkdown()
is not used by AngularJS or AngularJS Material.require('dgeni-packages/nunjucks')
and themarked
filter, i.e.{$ doc.description | marked $}
I read through the Marked release notes, but being unfamiliar with the library, I didn't really see anything related or of value to fixing this.
I read through this project's README.md but didn't see any references on how to use the
marked
filter.It looks like the code for the filter is here:
dgeni-packages/nunjucks/rendering/filters/marked.js
Lines 1 to 13 in 0fe303e
I don't see how a change to any
marked
APIs could cause issues with this simple filter.Except that it seems to call
renderMarkdown()
dgeni-packages/nunjucks/services/renderMarkdown.js
Lines 1 to 28 in 0fe303e
Which does import
marked
and use its APIs.There is perhaps something that I'm missing here where this can be fixed in the AngularJS and AngularJS Material projects, but from what I can tell, with limited knowledge of this library, the fix needs to be made here.
The text was updated successfully, but these errors were encountered: