简体   繁体   中英

How to adjust default font size of rendered markdown

I have a textarea which initially captures text with SimpleMDE (markdown) and is stored in mysql. On retrieval I use 'Marked' markdown renderer to display contents in a div, like this...

<div id="content" style="position:relative; width:auto; margin-left:10px; font-size:medium;"></div>
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script>document.getElementById('content').innerHTML = marked(`<?php echo nl2br($dispdesc); ?>`);</script>

I expected the font size (medium) defined in the div to be the default for all the text when diplayed, but it seems to only apply to lines of text which are bulleted and lines that follow that. The lines before the first bulleted line (or all lines if there are no bullets) appear in a much smaller text. Any ideas why this might be?

Here is some HTML output...

<div id="content" style="position:relative; width:auto; margin-left:10px; font-size:medium;"></div>
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script>document.getElementById('content').innerHTML = marked(`aaaaaaaaaa<br />
bbbbbbbbbbbbb<br />
bbbbb<br />
* cccccccccccccccccccc<br />
* ddddddddddddddddd<br />
eeeeeeeeeeeeeeeeee<br />
ffffffffffff<br />
`);</script>

Thanks to those who helped. I didn't work out what the problem was, but I am now testing a different strategy so have by-passed the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM