Skip to content

Commit

Permalink
Item15259: hyphenate p but not script or style
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDaum committed Jan 22, 2024
1 parent c3a0a57 commit 4dd18c3
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 12 deletions.
9 changes: 5 additions & 4 deletions data/System/HyphenationPlugin.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="micha" comment="reprev" date="1589888712" format="1.1" reprev="2" version="2"}%
%META:TOPICINFO{author="ProjectContributor" comment="reprev" date="1589888712" format="1.1" version="1"}%
---+!! %TOPIC%
%FORMFIELD{"Description"}%

Expand Down Expand Up @@ -55,7 +55,7 @@ So text in the =...= areas is hyphenated but not the =<pre>= or =<h2>= ele

---++ Examples

%HYPHENATE{"Straßenbahnschienenritzenreiniger" lang="de" hyphen="-"}%
%HYPHENATE{"Strassenbahnschienenritzenreiniger" lang="de" hyphen="-"}%

%HYPHENATE{"Incomprehensibilities" lang="en" hyphen="-"}%

Expand Down Expand Up @@ -92,15 +92,16 @@ intelligently monetize your enterprises to increase your big data velocity. Reli
---++ Change History

%TABLE{columnwidths="7em" tablewidth="100%"}%
| 22 Oct 2020 | initial release |
| 22 Jan 2024 | hyphenate <p> elements as well, but not <style> and <script> elements |
| 22 Oct 2020 | initial release |

%META:FORM{name="PackageForm"}%
%META:FIELD{name="Author" title="Author" value="Michael Daum"}%
%META:FIELD{name="Version" title="Version" value="%25$VERSION%25"}%
%META:FIELD{name="Release" title="Release" value="%25$RELEASE%25"}%
%META:FIELD{name="Description" title="Description" value="%25$SHORTDESCRIPTION%25"}%
%META:FIELD{name="Repository" title="Repository" value="https://github.com/foswiki/%25$ROOTMODULE%25"}%
%META:FIELD{name="Copyright" title="Copyright" value="2020, Michael Daum, All Rights Reserved"}%
%META:FIELD{name="Copyright" title="Copyright" value="2020-2024, Michael Daum, All Rights Reserved"}%
%META:FIELD{name="License" title="License" value="GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]])"}%
%META:FIELD{name="Home" title="Home" value="http://foswiki.org/Extensions/%25$ROOTMODULE%25"}%
%META:FIELD{name="Support" title="Support" value="http://foswiki.org/Support/%25$ROOTMODULE%25"}%
@@ -0,0 +1,50 @@
# Extension for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# HyphenationPlugin is Copyright (C) 2022-2024 Michael Daum http://michaeldaumconsulting.com
#
# 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 2
# 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, published at
# http://www.gnu.org/copyleft/gpl.html

package Foswiki::Configure::Checkers::Plugins::HyphenationPlugin::Enabled;

use strict;
use warnings;

use Foswiki::Configure::Checker ();
our @ISA = ('Foswiki::Configure::Checker');

my @modules = (
{
name => 'TeX::Hyphen',
usage => "",
minimumVersion => 0,
},
);

sub check_current_value {
my ($this, $reporter) = @_;

return unless $this->{item}->getRawValue();

Foswiki::Configure::Dependency::checkPerlModules(@modules);

foreach my $mod (@modules) {
if ($mod->{ok}) {
$reporter->NOTE(' * ' . $mod->{check_result});
} else {
$reporter->ERROR(' * ' . $mod->{check_result});
}
}
}

1;


7 changes: 4 additions & 3 deletions lib/Foswiki/Plugins/HyphenationPlugin.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, https://foswiki.org/
#
# HyphenationPlugin is Copyright (C) 2020 Michael Daum http://michaeldaumconsulting.com
# HyphenationPlugin is Copyright (C) 2020-2024 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -20,9 +20,10 @@ use warnings;

use Foswiki::Func ();

our $VERSION = '1.00';
our $RELEASE = '22 Oct 2020';
our $VERSION = '1.10';
our $RELEASE = '%$RELEASE%';
our $SHORTDESCRIPTION = 'Server-side hyphenation service';
our $LICENSECODE = '%$LICENSECODE%';
our $NO_PREFS_IN_TOPIC = 1;
our $core;

Expand Down
4 changes: 2 additions & 2 deletions lib/Foswiki/Plugins/HyphenationPlugin/Core.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, https://foswiki.org/
#
# HyphenationPlugin is Copyright (C) 2020 Michael Daum http://michaeldaumconsulting.com
# HyphenationPlugin is Copyright (C) 2020-2024 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -162,7 +162,7 @@ sub completePageHandler {
my $this = shift;

return unless defined $_[0];
return unless $_[0] =~ /<(?:div|span)\s+([^>]*?class=["'][^"']*?hyphenate[^>]*?)\s*>/;
return unless $_[0] =~ /<(?:div|span|p)\s+([^>]*?class=["'][^"']*?hyphenate[^>]*?)\s*>/;
return unless $_[1] =~ /Content-type: text\/html/;

_writeDebug("detected hyphenation");
Expand Down
1 change: 1 addition & 0 deletions lib/Foswiki/Plugins/HyphenationPlugin/MANIFEST
@@ -1,5 +1,6 @@
!noci
data/System/HyphenationPlugin.txt 0644
lib/Foswiki/Configure/Checkers/Plugins/HyphenationPlugin/Enabled.pm 0644
lib/Foswiki/Plugins/HyphenationPlugin/Config.spec 0644
lib/Foswiki/Plugins/HyphenationPlugin/Core.pm 0644
lib/Foswiki/Plugins/HyphenationPlugin/DEPENDENCIES 0644
Expand Down
5 changes: 2 additions & 3 deletions lib/Foswiki/Plugins/HyphenationPlugin/Parser.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, https://foswiki.org/
#
# HyphenationPlugin is Copyright (C) 2020 Michael Daum http://michaeldaumconsulting.com
# HyphenationPlugin is Copyright (C) 2020-2024 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -53,7 +53,6 @@ sub processText {

$this->parse($html);


foreach my $item (reverse @{$this->{_textPosList}}) {

my %p = %$params;
Expand Down Expand Up @@ -111,7 +110,7 @@ sub _start {
} elsif ($attr->{class} =~ /\bdonthyphenate\b/) {
$this->{_pauseDepth} = $this->{_depth};
}
} elsif ($tagName eq 'pre') {
} elsif ($tagName =~ /^(pre|script|style)$/) {
$this->{_pauseDepth} = $this->{_depth};
}

Expand Down

0 comments on commit 4dd18c3

Please sign in to comment.