This code snippet is functioning correctly, however, I have a suggestion to make it more appropriate. Instead of using '::before', why not try using '::marker'? I attempted this adjustment but encountered an issue. Can anyone explain why it didn't work as expected?
h1::before{content:'# '}
h2::before{content:'## '}
<h1>Level-1 heading</h1>
<h2>Level-2 heading</h2>
h1,h2,h3,h4,h5,h6{display:list-item}
h1::marker{content: '# '}
h2::marker{content: '## '}
<h1>Level-1 heading</h1>
<h2>Level-1 heading</h2>