summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2021-10-19 20:47:17 +0100
committerMichael Williamson <mike@zwobble.org>2021-10-19 20:47:17 +0100
commitebe0434a6eb0d43b92129cef7a59cb58a3f11cb7 (patch)
treeb0563c6aa0b82c2978904e207a876bc451ce9b2b
parent4b75771fb57ef42ea424fdcfb3a65e6c480f025d (diff)
Update document transform example for monospace fonts
-rw-r--r--README.md4
1 files changed, 3 insertions, 1 deletions
diff --git a/README.md b/README.md
index 90d85a6..3e8d3a1 100644
--- a/README.md
+++ b/README.md
@@ -544,10 +544,12 @@ var options = {
Or if you want paragraphs that have been explicitly set to use monospace fonts to represent code:
```javascript
+const monospaceFonts = ["consolas", "courier"];
+
function transformParagraph(paragraph) {
var runs = mammoth.transforms.getDescendantsOfType(paragraph, "run");
var isMatch = runs.length > 0 && runs.every(function(run) {
- return run.font && fonts.indexOf(run.font.toLowerCase()) !== -1;
+ return run.font && monospaceFonts.indexOf(run.font.toLowerCase()) !== -1;
});
if (isMatch) {
return {