Как я могу воспроизвести **bold** в моем шаблоне django?
Я пытаюсь воспроизвести, как stack overflow позволяет пользователю набирать текст и одновременно выводит его ниже. Код ниже в шаблоне Django работает для этого.
{% block head %}
<script>
function LiveTextUpdate() {
var x = document.getElementById("myInput").value;
document.getElementById("test").innerHTML = x;
}
</script>
{% endblock %}
{% block body %}
<div class = typing_container>
<div class = note_text>
{{ note_form.note }}
</div>
</div>
<div class = output_container>
<div class = output_note_text>
<p id="test" ></p>
</div>
</div>
В файле forms.py находится следующее:
class NoteForm(ModelForm):
class Meta:
model = NoteModel
fields = [
'note'
]
widgets = {
'note' : Textarea(attrs={'placeholder' : 'Start a new note', 'class' : 'updated_task_commentary', 'id' : 'myInput', 'oninput' : 'LiveTextUpdate()' }),
}
Как я могу повторить возможность выделения текста жирным шрифтом, когда текст окружен "**", пожалуйста?