-
Notifications
You must be signed in to change notification settings - Fork 8
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
Markdown preprocessing #1172
Markdown preprocessing #1172
Conversation
Pulling new changes.
Pull in new changes
|
||
let addNewLines = description: string => { | ||
let duplicateNewLines = Js.String.replaceByRe([%re "/[\\n]/g"], "\n\n", description); | ||
let pruneCuatrupleLines = Js.String.replaceByRe([%re "/[\\n\\n\\n\\n]/g"], "\n\n", duplicateNewLines); |
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.
"quatruple" -> "quadruple".
Also, This would make it impossible for anyone who wanted 4 newlines, I assume?
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 seems like a decently hacky situation to me. I realize it's a tricky thing though.
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.
You can't have 4 newlines right now. Try it.
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.
(Fixed the "quatruple" -> "quadruple" typo)
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.
Does the solution seem less hacky to you given that the 4 newlines is not a problem?
Some other things I was worried about were:
- Ordered lists breaking if you added an additional newline
- Tables
But I checked for that (https://www.foretold.io/c/e351f8f3-cf9c-4787-a787-68257220084d/m/012b73bf-82d2-4c70-9c85-644f2685fc68), and it is not a problem.
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.
I think you've convinced me that this is a justified feature, but I think doing it well and right will be more work.
Links you previously shared in slack:
https://meta.stackexchange.com/questions/26011/should-the-markdown-renderer-treat-a-single-line-break-as-br
https://meta.stackexchange.com/questions/40976/what-is-the-reason-for-the-top-secret-two-space-newline-markdown-weirdness
@@ -16,7 +16,7 @@ let make = (~measurable: Types.measurable, ~defaultValueText="") => { | |||
measurable.id, | |||
value, | |||
competitorType, | |||
description, | |||
MeasurementCdfInput.MarkdownPreprocessing.addNewLines(description), |
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.
If we do this, we should probably have it apply to all markdown renders, not just measurement inputs.
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.
I think you've convinced me that this is a justified feature, but I think doing it well and right will be more work.
Plausibly. Another possibility would be to move to Github flavored markdown, or to some implementation (https://simplemde.com/?) which doesn't have the line break problem.
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.
Agree that it makes sense to have it on other renderers too
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.
I think Github does do this for new lines. I would prefer to move to Github flavored or another standard one that has them, instead of us coming up with our own hybrid, but was assuming that would be more work.
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.
So coming up with our hybrid might be a nightmare. For example, if you want to preserve newlines within codeblocks (```), then you either have to write a parser, or some really ugly regular expressions. I was briefly looking into the Github Flavored Markdown specs: https://github.github.com/gfm, and I'm just glad someone else did it.
In this case I'd push for either.
- Just do the hack for comments, but maybe not for notebooks
- Move to github flavored markdown, or to another specification and/or a better editor.
I have some intuitions that in this case, the hack is better, but I also wouldn't mind the second option. I dislike the option in between, the "write your own principled hybrid".
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.
Apparently we may be able to implement github flavored markedown with our current react-markdown package, though of course I'm not sure exactly how hard it would be. https://github.com/rexxars/react-markdown/blob/c63dccb8185869cfc73c257d098a123ef7a7cd33/demo/src/demo.js
I'm hesitant to go forward with this as in (1), it just makes me feel uneasy. Hacks like that can really bite, we've probably gone too far that type of direction already.
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.
It's possible we can use a plugin for this. remarkjs/react-markdown#105
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.
Oh, cool
Jacob Laguerros said on slack:
This pull request adds newlines as the comments are sent to the database so that this is not a problem anymore, for new messages / comments.