I'm having trouble troubleshooting an issue on provemath where the content is not rendering as desired.
The problem is that each line (except for the first) in written content is wrapped in a <div>
. For example, the content
line1.
line2.
as you can see through the Safari web inspector is actually rendered as <p>line1.<div>line2.</div></p>
. The DESIRED output is <p>line1.<br>line2.</p>
.
There are a few things that could be coming into play here...
flexbox
was causing this, but I changed the CSS to no avail.Content rendering happens as follows:
Content is typed by user (hitting RETURN for a new line) and captured with jQuery's .html
function
blind.value = $value.html()
to get the content, and then processed with
function render_content(string) {
// make all \ into \\ instead, so that they will be \ again when marked is done. This is for MathJax postrender compatability.
string = string.replace(/\\/g, '\\\\')
string = string.replace(/\n/g, '<br />') // not doing anything AFAIK
string = marked(string)
string = string.replace(/img(\d+)/g, '<img src="image/$1.jpg" />')
string = string.replace(/\\includegraphics\{(.*?)\}/g, '<img src="image/$1.jpg" />')
return string
}
The CSS is as follows:
.value {
// display: inline-flex;
display: inline;
// flex-direction: column;
vertical-align: top;
width: 85%;
}
you can see the old CSS commented out.
If you've faced the situation when you need to wrap words in a <div>, you can use the white-space property with the "pre-wrap" value to preserve whitespace by the browser and wrap the text when necessary and on line breaks. Also, you'll need the word-wrap property.
You have to set 'display:inline-block' and 'height:auto' to wrap the content within the border. Show activity on this post. Two ways are there. No need to mention height in this it will be auto by default.
If you want to prevent the text from wrapping, you can apply white-space: nowrap; Notice in HTML code example at the top of this article, there are actually two line breaks, one before the line of text and one after, which allow the text to be on its own line (in the code).
Why are you processing 'backslash' before 'newline'? Have you tried this?
string = string.replace(/\n/g, '<br />')
string = string.replace(/\\/g, '\\\\')
string = marked(string)
try wrapping both lines in a div, then using css grid to render them as you like. Here is a link documenting the css grid.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With