Skip to content

Commit

Permalink
fix: regex of drop cap and indent
Browse files Browse the repository at this point in the history
  • Loading branch information
reuixiy committed Jan 16, 2020
1 parent 6bb169d commit e4d4fd8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions layouts/partials/components/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
{{- end -}}
{{- $enableDropCap := .Scratch.Get "enableDropCap" -}}
{{- if $enableDropCap -}}
{{- $regexPatternDropCap := `(<p)(>)(.)([^<]+)` -}}
{{- $regexPatternDropCap := `(<p)(>)([^<])(.+(</p>|\n))` -}}
{{- $regexReplacementDropCap := `$1 style="text-indent:0"$2<span class="drop-cap">$3</span>$4` -}}
{{- $firstParagraphOld := (delimit (findRE $regexPatternDropCap $Content 1) " ") -}}
{{- $firstParagraphNew := (replaceRE $regexPatternDropCap $regexReplacementDropCap $firstParagraphOld) -}}
Expand All @@ -77,7 +77,7 @@
{{- end -}}
{{- $replacement := .Scratch.Get "replacement" -}}

{{- $regexPatternDropCapAfterHr := `(\n(<hr />|<hr>))(\n<p)(>)(.)` -}}
{{- $regexPatternDropCapAfterHr := `(\n(<hr />|<hr>))(\n<p)(>)([^<])` -}}
{{- $regexReplacementDropCapAfterHr := $replacement -}}
{{- $Content := $Content | replaceRE $regexPatternDropCapAfterHr $regexReplacementDropCapAfterHr | safeHTML -}}
{{- .Scratch.Set "Content" $Content -}}
Expand Down Expand Up @@ -200,10 +200,10 @@
{{- end -}}
{{- $Content := .Scratch.Get "Content" -}}
{{- if not $enableDropCapAfterHr -}}
{{- $regex := `((</h[1-6]>|<hr>|<hr />)\n<p)(>)` -}}
{{- $regex := `((</h[1-6]>|<hr>|<hr />)\n<p)(>)[^<]` -}}
{{- $.Scratch.Set "regex" $regex -}}
{{- else -}}
{{- $regex := `((</h[1-6]>)\n<p)(>)` -}}
{{- $regex := `((</h[1-6]>)\n<p)(>)[^<]` -}}
{{- $.Scratch.Set "regex" $regex -}}
{{- end -}}
{{- $regex := .Scratch.Get "regex" -}}
Expand Down

0 comments on commit e4d4fd8

Please sign in to comment.