-
Notifications
You must be signed in to change notification settings - Fork 123
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
bugfix: Fix hrefs for headings with angular brackets #1089
Conversation
4fd5b21
to
8d66580
Compare
@ang-zeyu could I get your review on this? |
Realised that the con of this fix is that you cant type
|
Good catch 😅
Yup, I've now changed it to use the previously suggested fix. This will remove all occurrences of |
src/lib/markbind/src/parser.js
Outdated
@@ -263,7 +263,9 @@ class Parser { | |||
|
|||
if ((/^h[1-6]$/).test(node.name) && !node.attribs.id) { | |||
const textContent = utils.getTextContent(node); | |||
const slugifiedHeading = slugify(textContent, { decamelize: false }); | |||
let cleanedContent = textContent.replace(/</g, ''); | |||
cleanedContent = cleanedContent.replace(/>/g, ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, I've now changed it to use the previously suggested fix.
👍
Why not combine it into one though <|>
:o
A comment here explaining why we clean <>
in particular might be nice too
I suppose that this PR is trivial enough to be merged after 1 approval |
sorry for deleting comment.
yeah, i don't really know if anything will regress after this. No clean unit test for this because these functionality lies within If anything, the fact that this link |
Yup, it can be merged. 🙂 |
* 'master' of https://github.com/MarkBind/markbind: (41 commits) Document adding new site content in DG (MarkBind#1153) Add relative date feature (MarkBind#908) Use <br> to separate lines of code block (MarkBind#1176) Parse popovers for footnotes (MarkBind#1155) Resolve comments Expand test extensions and fix whitespace checks (MarkBind#1156) Address comments Upgrade js-beautify and provide option to turn it off (MarkBind#1116) Normalize inline puml line ending before hashing (MarkBind#1174) Update tests (MarkBind#1178) Remove fixed bugs from test\functional\test_site\bugs\index.md` (MarkBind#1148) Fix bug in Search for UG and DG (MarkBind#1147) Add inline puml support (MarkBind#1100) Fix hrefs for headings with angular brackets (MarkBind#1089) Update tests for 2.13.1 (MarkBind#1169) 2.13.1 Update vue-strap version to v2.0.1-markbind.39 Fix fontawsome icons don't show underlines to indicate modal/tooltip (MarkBind#1133) 2.13.0 Update test files ...
``` The hrefs of headings with angular brackets are incorrect because markdown-it escapes the characters to "<" and ">" and the subsequent slugify operation converts it to "and-lt" or "and-gt". Let's fix this by removing the occurrences of the strings "<" and ">" before the slugify operation ```
What is the purpose of this pull request? (put "X" next to an item, remove the rest)
• [x] Bug fix
Fixes #1076
What is the rationale for this request?
Presence of angular brackets in headings creates undesirable href links.
What changes did you make? (Give an overview)
Removed occurrences of the strings
'and lt'
and'and gt'
that are passed toslugify
.Provide some example code that this change will affect:
customReplacements: [['and lt', ''],['and gt', ''],],});New fix:
Is there anything you'd like reviewers to focus on?
n/a
Proposed commit message: (wrap lines at 72 characters)