-
Notifications
You must be signed in to change notification settings - Fork 2
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: close unclosed tags in html parser and trim indentation of md content lines #332
fix: close unclosed tags in html parser and trim indentation of md content lines #332
Conversation
@@ -82,7 +82,7 @@ module.exports = function (body, config, docPath) { | |||
function (_, indent, openTag, content) { | |||
attrs = getAttrs(openTag, docPath, config); | |||
|
|||
if (config.org === attrs.org) return `${indent}${content}`; | |||
if (config.org === attrs.org && config.countryCode === attrs.country ) return `${indent}${content}`; |
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.
We had added a new attribute org-country
earlier, which TWs are using now. Does that also need to be checked here?
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.
Will check this and update
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.
support for this will be added later. For now, this attribute is only used for razorpay-IN org and axis org.
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.
org-country attribute has been used for razorpay-IN and axis-IN. That content will get skipped if we don't check for it.
Logic for this is in docs-website webpack-loaders/remark-plugins/remark-plugin-whitelabel/index.js
. Might need to duplicate that code here.
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.
For now, this attribute is only used for razorpay-IN org and axis org.
Why is this not being used for Curlec?
build-search.js
Outdated
const parsedContentWithFrontmatter = { | ||
...parsedContent, | ||
...doc.frontMatter, | ||
body: content, | ||
href: doc.href, | ||
content: parsedContent.content.split('\n').join(''), |
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.
Question: Why is this required? Is this another thing which was missed earlier?
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.
Will add a comment on this
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.
This is done to remove the extra spacing and trim down the html dom string
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.
Please add this as a comment in code
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.
Approved with 2 comments
@@ -82,7 +82,7 @@ module.exports = function (body, config, docPath) { | |||
function (_, indent, openTag, content) { | |||
attrs = getAttrs(openTag, docPath, config); | |||
|
|||
if (config.org === attrs.org) return `${indent}${content}`; | |||
if (config.org === attrs.org && config.countryCode === attrs.country ) return `${indent}${content}`; |
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.
org-country attribute has been used for razorpay-IN and axis-IN. That content will get skipped if we don't check for it.
Logic for this is in docs-website webpack-loaders/remark-plugins/remark-plugin-whitelabel/index.js
. Might need to duplicate that code here.
@@ -82,7 +82,7 @@ module.exports = function (body, config, docPath) { | |||
function (_, indent, openTag, content) { | |||
attrs = getAttrs(openTag, docPath, config); | |||
|
|||
if (config.org === attrs.org) return `${indent}${content}`; | |||
if (config.org === attrs.org && config.countryCode === attrs.country ) return `${indent}${content}`; |
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.
For now, this attribute is only used for razorpay-IN org and axis org.
Why is this not being used for Curlec?
Changes Made :
Extend md utitlity to close unclosed tags.
Reason : In Citadel's markdown to html parser, some tags were left unclosed which generates incorrect html syntax. This generated html is used to build Algolia records.
Until now, we were not doing HAST parsing while building Algolia records, hence, this error went unnoticed. Now, we are parsing HAST for generating granular search records. Hence need this fix.
Trim indentation of md content before rendering to html
Reason: if content is not trimmed, then this results in incorrect interpretation of indentation resulting in errors like adding codeblocks whenver indentation > 3 etc. One more benefit of this is that record size is decreased by a great extent. No of heaving records decreased from 12 to 4.