From: Nick Bowler Date: Sun, 21 Jun 2020 16:14:01 +0000 (-0400) Subject: Add spaces in self-closing XML tags. X-Git-Url: https://git.draconx.ca/gitweb/homepage.git/commitdiff_plain/ff1ac7e6d5d6acb82977353b9155a276a8077980 Add spaces in self-closing XML tags. Some very old browsers that do not implement XHTML get confused by tags like
but have no problem with
. This is very easy to accomodate so let's do it. --- diff --git a/Rules b/Rules index d0a81fb..a7dffee 100644 --- a/Rules +++ b/Rules @@ -1,6 +1,6 @@ #!/usr/bin/env ruby # -# Copyright © 2018-2019 Nick Bowler +# Copyright © 2018-2020 Nick Bowler # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -54,6 +54,7 @@ compile '/license/gpl*.md' do layout '/gpl.xsl' layout '/default.xsl' filter :relativize_paths, type: :xml + filter :xhtml_compat filter :remove_wj write to_xhtml end @@ -65,6 +66,7 @@ compile '/**/*.md' do layout '/default.xml' layout '/default.xsl' filter :relativize_paths, type: :xml + filter :xhtml_compat filter :remove_wj write to_xhtml end @@ -75,6 +77,7 @@ compile '/license/cc*.sgml' do layout '/default.xml' layout '/default.xsl' filter :relativize_paths, type: :xml + filter :xhtml_compat filter :remove_wj write to_xhtml end @@ -84,6 +87,7 @@ compile '/license/cc*.xhtml' do layout '/default.xml' layout '/default.xsl' filter :relativize_paths, type: :xml + filter :xhtml_compat filter :remove_wj write to_xhtml end diff --git a/lib/xhtml-compat.rb b/lib/xhtml-compat.rb new file mode 100644 index 0000000..f69c1ee --- /dev/null +++ b/lib/xhtml-compat.rb @@ -0,0 +1,25 @@ +# Nick's web site: xhtml_compat filter. Add whitespace before the end +# of empty element tags to improve compatibility with old browsers. +# +# Copyright © 2020 Nick Bowler +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +class XhtmlCompatFilter < Nanoc::Filter + identifier :xhtml_compat + + def run(content, params = {}) + return content.gsub(/([^[:space:]])\/>/m, '\1 />'); + end +end