Skip to content

Commit

Permalink
Merge pull request #11 from oveleon/develop
Browse files Browse the repository at this point in the history
Fixes #10 - Consider opening parenthesis in regex
  • Loading branch information
zoglo authored Jan 15, 2022
2 parents f42783b + e0cf055 commit 5dd64ea
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 40 deletions.
28 changes: 14 additions & 14 deletions src/Resources/contao/templates/glossary/glossary_full.html5
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@

<h1><?= $this->headline ?></h1>

<?php if ($this->hasSubHeadline): ?>
<?php if ($this->hasSubHeadline): ?>
<h2><?= $this->subHeadline ?></h2>
<?php endif; ?>
<?php endif; ?>

<?php if ($this->hasText): ?>
<?= $this->text ?>
<?php else: ?>
<?php if ($this->hasText): ?>
<?= $this->text ?>
<?php else: ?>
<div class="ce_text block">
<?php if (!$this->addBefore): ?>
<?= $this->teaser ?>
<?php endif; ?>
<?php if (!$this->addBefore): ?>
<?= $this->teaser ?>
<?php endif; ?>

<?php if ($this->addImage): ?>
<?php $this->insert('image', $this->arrData); ?>
<?php endif; ?>
<?php if ($this->addImage): ?>
<?php $this->insert('image', $this->arrData); ?>
<?php endif; ?>

<?php if ($this->addBefore): ?>
<?= $this->teaser ?>
<?php endif; ?>
<?php if ($this->addBefore): ?>
<?= $this->teaser ?>
<?php endif; ?>
</div>
<?php endif; ?>

Expand Down
14 changes: 7 additions & 7 deletions src/Resources/contao/templates/glossary/glossary_latest.html5
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@

<h4><?= $this->linkHeadline ?></h4>

<?php if ($this->addImage): ?>
<?php $this->insert('image', $this->arrData); ?>
<?php endif; ?>
<?php if ($this->addImage): ?>
<?php $this->insert('image', $this->arrData); ?>
<?php endif; ?>

<div class="ce_text block">
<?= $this->teaser ?>
<?= $this->teaser ?>
</div>

<?php if ($this->hasText || $this->hasTeaser): ?>
<p class="more"><?= $this->more ?></p>
<?php endif; ?>
<?php if ($this->hasText || $this->hasTeaser): ?>
<p class="more"><?= $this->more ?></p>
<?php endif; ?>

</div>
8 changes: 4 additions & 4 deletions src/Resources/contao/templates/glossary/glossary_short.html5
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<h4><?= $this->linkHeadline ?></h4>

<div class="ce_text block">
<?= $this->teaser ?>
<?= $this->teaser ?>
</div>

<?php if ($this->hasText || $this->hasTeaser): ?>
<p class="more"><?= $this->more ?></p>
<?php endif; ?>
<?php if ($this->hasText || $this->hasTeaser): ?>
<p class="more"><?= $this->more ?></p>
<?php endif; ?>

</div>
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@

<div id="g_hovercard_<?= $this->id ?>" class="g_hovercard_default item">

<?php if ($this->addImage): ?>
<?php $this->insert('image', $this->arrData); ?>
<?php endif; ?>
<?php if ($this->addImage): ?>
<?php $this->insert('image', $this->arrData); ?>
<?php endif; ?>

<strong class="g_hovercard-keyword"><?= $this->headline ?></strong>

<div class="g_hovercard-text ce_text block">
<?= $this->teaser ?>
<?= $this->teaser ?>
</div>

<?php if ($this->hasText || $this->hasTeaser): ?>
<p class="g_hovercard-link more"><?= $this->more ?></p>
<?php endif; ?>
<?php if ($this->hasText || $this->hasTeaser): ?>
<p class="g_hovercard-link more"><?= $this->more ?></p>
<?php endif; ?>

</div>
9 changes: 5 additions & 4 deletions src/Resources/contao/templates/modules/mod_glossary.html5
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ul>
<?php foreach ($this->availableGroups as $group): ?>
<li class="<?= $group['class'] ?>">
<?= $group['item'] ?>
<?= $group['item'] ?>
</li>
<?php endforeach; ?>
</ul>
Expand All @@ -16,22 +16,23 @@
<p class="empty"><?= $this->empty ?></p>
<?php else: ?>

<?php if ($this->hasQuickLinks): ?>
<?php if ($this->hasQuickLinks): ?>
<ul>
<?php foreach ($this->quickLinks as $link): ?>
<li><?= $link ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<?php endif; ?>

<div class="glossary">
<?php foreach ($this->glossarygroups as $letter => $group): ?>
<div class="group" id="<?= $group['id'] ?>">
<div class="letter"><?= $letter ?></div>
<?= implode("",$group['items']) ?>
<?= implode("",$group['items']) ?>
</div>
<?php endforeach; ?>
</div>

<?php endif; ?>

<?php $this->endblock(); ?>
6 changes: 3 additions & 3 deletions src/Resources/public/scripts/Glossary.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export class Glossary

for (const term of this.options.config)
{
const rgx = new RegExp("(?:\\s|>|^)(" + term.keywords.join('|') + ")\\b", term.cs ? 'gu' : 'giu')
const rgx = new RegExp("(?:\\s|>|^|\\()(" + term.keywords.join('|') + ")\\b", term.cs ? 'gu' : 'giu')

const matches = node.textContent.matchAll(rgx)

Expand All @@ -185,7 +185,7 @@ export class Glossary
// Lookbehind in JS regular expressions ( ?>= ) : https://caniuse.com/js-regexp-lookbehind
if(this.isNewIE)
{
const matchRgx = new RegExp("(?:>|^)(" + match + ")\\b", 'gu')
const matchRgx = new RegExp("(?:>|^|\\()(" + match + ")\\b", 'gu')
let sentence = [];

for(let word of node.textContent.split(' '))
Expand All @@ -201,7 +201,7 @@ export class Glossary
else
{
// Lookbehind regex for other browsers
const matchRgx = new RegExp("(?<=\\s|>|^)(" + match + ")\\b", 'gu')
const matchRgx = new RegExp("(?<=\\s|>|^|\\()(" + match + ")\\b", 'gu')
node.textContent = node.textContent.replace(matchRgx, elementMarkup)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/public/scripts/dist/main.js

Large diffs are not rendered by default.

0 comments on commit 5dd64ea

Please sign in to comment.