私は現在、マークダウン ファイルで動作するオンライン テキスト編集システムに取り組んでいます。エディターは正常に動作します (ユーザーがファイルを編集している間、マークダウン入力はプレビュー用に mark.min.js で解析されます) が、表示専用の目的でページを実装するときに奇妙な問題が発生しました。
同じマークダウン パーサーを使用したいので、クライアント側で mark.min.js を使用してファイルを解析する必要があります<pre>
。マークダウン ファイルは、通常のテキスト エディター (最も読みやすい形式) と同じように表示されます。テキストを解析してフォーマットされたテキストに置き換えるには、次を使用します。
window.onload=function(){
document.getElementById('markdown-description').innerHTML =
marked(document.getElementById('markdown-raw').innerHTML);
}
ただし、エディターで機能している間、何らかの形ですべての引用符がすべて解析されていないことがわかります。>
パーサーを無効にして<pre>
タグ間のマークダウン ファイルを表示すると、すべてのマークが表示されます。以下でも動作します:
window.onload=function(){
document.getElementById('markdown-description').innerHTML =
marked('# This\n\This is a HTML5 Markdown editor.\n\n> The overriding design goal for Markdown\'s\n> formatting syntax is to make it as readable\n> as possible.\n\nThis text you see here ');
}
誰かがなぜこれがうまくいかないのか説明できますか?
私のHTMLコード:
<div class="description" id="markdown-description"><pre id="markdown-raw"> # Dillinger
Dillinger is a cloud-enabled, mobile-ready, offline-storage, AngularJS powered HTML5 Markdown editor.
- Type some Markdown on the left
- See HTML in the right
- Magic
Markdown is a lightweight markup language based on the formatting conventions that people naturally use in email. As [John Gruber] writes on the [Markdown site][df1]
> The overriding design goal for Markdown's
> formatting syntax is to make it as readable
> as possible. The idea is that a
> Markdown-formatted document should be
> publishable as-is, as plain text, without
> looking like it's been marked up with tags
> or formatting instructions.
This text you see here </pre></div>