Closed Ailothaen closed 5 years ago
Hello, Thanks for reporting this bug, I'll take a look.
Can you try this solution : replace the function post_markup()
in admin/ecrire.php` with this https://gist.github.com/remrem/adebe8a1f5c16d548c6c2e69c68c0d4c (2 functions)
When you write an article with <code>...</code>
or <pre>...</pre>
, the parser will replace <code>...</code>
or <pre>...</pre>
by <html_code>
, then continue to convert and at the end will replace '<code>...</code>
or <pre>...</pre>
.
You can use multiple <code>...</code>
and <pre>...</pre>
in the same article, and you can use attributs (class, id ...) <code class="example">...</code>
.
I tested it and it seems to work. I use <pre><code class="lang">...</code></pre>
for syntax highlighting (I use highlight.js) and it keeps everything, good job!
The links are no longer "tagged" as well.
I come back on this suggestion, because I actually noticed some problems (I only did check if it was working...)
Although the <pre><code>
combination seems to work, the simple [code] tag no longer works: the [code]
tag is displayed in the formatted text, with the inside content without formatting on it... like the tag does not exist anymore.
Also, I've noticed a weird thing about the <pre><code>
blocks: a paragraph immediately after will not have an opening <p>
tag, only a closing one. It also has a <br />
coming out of nowhere. Here is an example:
<p>Si le flux RSS est inscrit dans la page, il apparaît dans le <head> du code source HTML, sous cette forme :</p>
<p><pre><code class="html"><link rel="alternate" type="application/rss+xml" title="RSS - Articles" href="rss.php" />
<link rel="alternate" type="application/atom+xml" title="ATOM - Articles" href="atom.php" /></code></pre><br />
Il existe des extensions navigateur (<a href="https://addons.mozilla.org/fr/firefox/addon/awesome-rss/">Firefox</a>, <a href="https://chrome.google.com/webstore/detail/get-rss-feed-url/kfghpdldaipanmkhfpdcjglncmilendn?hl=fr">Chrome</a>) pour récupérer automatiquement le lien. Sous Firefox, il existe même un bouton RSS natif (qu'il faut activer en personnalisant l'interface), mais je ne recommande pas son utilisation car il ne permet pas d'obtenir facilement le lien.<br />
Sinon, il existe toujours la solution... de parcourir le code source !</p>
I think I know what the problem is, can you post here the text you're writing, at least the extract that causes the problem?
If you mean the text in the admin section, here it is;
Si le flux RSS est inscrit dans la page, il apparaît dans le <head> du code source HTML, sous cette forme :
<pre><code class="html"><link rel="alternate" type="application/rss+xml" title="RSS - Articles" href="rss.php" />
<link rel="alternate" type="application/atom+xml" title="ATOM - Articles" href="atom.php" /></code></pre>
Il existe des extensions navigateur ([Firefox|https://addons.mozilla.org/fr/firefox/addon/awesome-rss/], [Chrome|https://chrome.google.com/webstore/detail/get-rss-feed-url/kfghpdldaipanmkhfpdcjglncmilendn?hl=fr]) pour récupérer automatiquement le lien. Sous Firefox, il existe même un bouton RSS natif (qu'il faut activer en personnalisant l'interface), mais je ne recommande pas son utilisation car il ne permet pas d'obtenir facilement le lien.
Sinon, il existe toujours la solution... de parcourir le code source !
I posted the result source code and "view" just above.
Thanks for the extract,
Can you try replacing the functions of my previous gist post_markup()
and parse_texte_code_html()
with this one https://gist.github.com/remrem/adebe8a1f5c16d548c6c2e69c68c0d4c (the same gist, updated).
Details :
post_markup()
which implies ignoring [code]
-yep, I'm an idiot-<code>
and </pre>
to pass them into BT's parser and re-inject the content towards the end of the process.<>
in <code>
, the script will encode them automaticallyIt seems to work for real now. Great, thanks again! :owl:
:) I keep this issue open until the BT 3.7.7 release.
Hey :owl:
I'm using the
<pre>
(alongside with<code>
) tag directly when redacting articles, for some reasons (especially because I use a syntax highlighting library) The<pre>
tag is supposed to render line-breaks, tabs, spaces... exactly as they were in the article (so for example, the line-breaks are displayed as line-breaks, we don't need to use<br>
) However, it seems that Blogotext automatically inserts<br>
tags within<pre>
elements, which results as double-line-breaks:So this is an unwanted behavior, as
<pre>
already "manages" line-breaks by himself. Also, there is the same problem with the link detection : Blogotext also markups the links (i.e. text beginning by http://, https://, ...) in<pre>
tags, which could result to bugs.I've tried to implement a fix for that, but did not succeeded. Here's an useful regexp I found, that seems to work:
$clean = preg_replace('#<br\s*\/>(?=(?:(?!<\/?pre>)[\s\S])*<\/pre>)#', '', $unclean);