Skip to content

Commit 2820efe

Browse files
committed
Add pandoc.blocks.CodeBlock.html property
1 parent 6ec9f48 commit 2820efe

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

quartodoc/pandoc/blocks.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ def __str__(self):
179179
{content}
180180
```\
181181
"""
182+
CodeBlockHTML_TPL = """\
183+
<pre{attr}>
184+
<code>{content}</code>
185+
</pre>\
186+
"""
182187

183188

184189
@dataclass
@@ -210,6 +215,21 @@ def __str__(self):
210215

211216
return CodeBlock_TPL.format(content=content, attr=attr)
212217

218+
@property
219+
def html(self):
220+
"""
221+
Code (block) rendered as html
222+
223+
Notes
224+
-----
225+
Generates html as if the `--no-highlight` option as passed
226+
to pandoc
227+
"""
228+
content = self.content or ""
229+
attr = f" {self.attr.html}" if self.attr else ""
230+
return CodeBlockHTML_TPL.format(content=content, attr=attr)
231+
232+
213233

214234
@dataclass
215235
class BulletList(Block):

quartodoc/pandoc/inlines.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ def __str__(self):
136136
def html(self):
137137
"""
138138
Code (inline) rendered as html
139+
140+
Notes
141+
-----
142+
Generates html as if the `--no-highlight` option as passed
143+
to pandoc
139144
"""
140145
content = self.text or ""
141146
attr = f" {self.attr.html}" if self.attr else ""

0 commit comments

Comments
 (0)