You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by zr...@apache.org on 2019/08/07 15:06:02 UTC

[camel-website] branch master updated: chore: remove inline styles in asciidoc content

This is an automated email from the ASF dual-hosted git repository.

zregvart pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-website.git


The following commit(s) were added to refs/heads/master by this push:
     new 2d6721d  chore: remove inline styles in asciidoc content
2d6721d is described below

commit 2d6721da857a6188633ccb86a29da7cb97b11c12
Author: Zoran Regvart <zr...@apache.org>
AuthorDate: Wed Aug 7 17:05:58 2019 +0200

    chore: remove inline styles in asciidoc content
    
    With the content security policy set to disable any inline styles any
    inline styles that are present are not taken into account. This adds a
    Asciidoctor.js extension to remove all inline styles from the rendered
    HTML to reduce the number of errors reported in the Google search
    console and the browser console.
---
 extensions/inline-styles.js | 9 +++++++++
 site.yml                    | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/extensions/inline-styles.js b/extensions/inline-styles.js
new file mode 100644
index 0000000..99435ed
--- /dev/null
+++ b/extensions/inline-styles.js
@@ -0,0 +1,9 @@
+function removeInlineStyle() {
+  this.process((doc, output) => {
+    return output.replace(/\s*style="[^"]+"\s*/g, '')
+  })
+}
+
+module.exports.register = (registry, context) => {
+  registry.postprocessor(removeInlineStyle)
+}
diff --git a/site.yml b/site.yml
index 16657b1..78243cc 100644
--- a/site.yml
+++ b/site.yml
@@ -31,4 +31,4 @@ output:
 asciidoc:
   extensions:
     - ./extensions/table.js
-
+    - ./extensions/inline-styles.js