Commit 76659db4 authored by julien's avatar julien

add simple emdash replacement regex example

parent fcd805b9
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
} }
</style> </style>
<!-- call the paged.js polyfill --> <!-- call the paged.js polyfill -->
<script src="https://unpkg.com/pagedjs/dist/paged.polyfill.js"></script> <script src="https://unpkg.com/pagedjs/dist/paged.polyfill.js"></script>
...@@ -34,6 +37,17 @@ ...@@ -34,6 +37,17 @@
beforeParsed(content) { beforeParsed(content) {
console.log(content); console.log(content);
smartquotes(content); smartquotes(content);
// replace the dash using regex
var regexCapital = /--/g;
// look for all element inside the body
var dash = document.querySelectorAll("body *");
// for each of those elements
dash.forEach(element => {
// replace ` -- ` with `&mdash;`
element.innerHTML = element.innerHTML.replace(regexCapital, '&mdash;')
})
} }
} }
// register the hook: // register the hook:
...@@ -45,5 +59,6 @@ ...@@ -45,5 +59,6 @@
<body> <body>
<h1>"smartquote" and “key pressed smartquotes”</h1> <h1>"smartquote" and “key pressed smartquotes”</h1>
<p>"smartquote" and “ key pressed smartquotes”</p> <p>"smartquote" and 'key pressed smartquotes'</p>
<p>em "dash" -- 'key pressed smartquotes'</p>
</body> </body>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment