Comments (12)
For the <hr/>
, we might convert it to <hr></hr>
first, than parse for <p>
and in the end convert it back to <hr/>
. It’s a bit like Gecko DOM parser seem to work : the DOM tree also contains such things as <br></br>
(even if the source document does not).
I’m open to other suggestions for this.
I’ll be happy to see the PR for the refactoring in either cases and put it to the tests.
I’m also asking myself if this function could need a major refactoring, using LibXML. But it could heavily conflict if the user input contains non-valid HTML, scripts or other stuff.
The purpose of this function is to make nicer HTML (instead of doing a nl2br()
). This is usefull for applications like Pocket™, Readability.js and screen-readers that format paragraphs in specific ways.
from blogotext.
In theory the user input is BBCode formated. For the few who write raw HTML, if the code is bad it is not an error of BlogoText. I used to write raw HTML sometimes but now there is [code=language]
.
If there were a hr
BBCode I think I will not have to write raw HTML anymore.
Do you know if a lot of people write scripts into the post content?
Perhaps you could use a function with libXML and in case of error fallback to this function?
from blogotext.
I use much of HTML all the time. No BBCode or markdown will replace its power.
A native HR tag in BBCode could help, and there was such a tag in the past but it would not solve the problem here : parse_texte_paragraphs()
always gets HTML as parameter. So the BBCode would be transformed to HTML before the functions is called.
For that, at this point I don’t have any other idea than the intermediate tag (the same trick I use for the [code]
tag, transformed into <prebtcode>
and then in <pre>
.
from blogotext.
You are right, using the same trick will be OK.
I will send the PR after your modifications, it is nothing big.
from blogotext.
It is done for the hr
.
I noticed that the tbody
element was forgotten in the block elements and added it also.
from blogotext.
It is much better :)
I just found that input
blocks are wrong, but it is an unusual special case.
from blogotext.
You mean output
?
from blogotext.
No, input
of forms.
I do not think it is needed to handle this case.
from blogotext.
I don’t understand : which inputs?
from blogotext.
I talking about manually add a form
into a post :)
from blogotext.
Aha! But I didn’t planned to support that :O
If we really want to support the totality of HTML elements, we should add them all, and make a special regex for all the self-closing HTML tags.
It might then become quite hard to do to support everything : attributes for instance, can contain actual HTML and/or JS (with fancy characters, including HTML). It’s not impossible but it might be very tricky:
http://lehollandaisvolant.net/?mode=links&id=20130322003640
http://lehollandaisvolant.net/?mode=links&id=20130322223827
IMHO, there would be too much energy put into that for something not widely used and already having a solution.
There is an easy way to make everything work fine, that is not using any \n
in the text you enter.
So, don’t do this:
<form>
<fieldset>
<label for="input">Blah</label>
<input id="Blah" value="something here"/>
</fieldset>
</form>
But this:
<form><fieldset><label for="input">Blah</label><input id="Blah" value="something here"/></fieldset></form>
It is dirty and undocumented, but it works and does validate with W3.
from blogotext.
Thanks for the trick! And yes, you are right, no need to implement such a thing ^^
from blogotext.
Related Issues (20)
- GZIP et minify (css, js, html) HOT 3
- Deprecated functions HOT 8
- Another warning HOT 2
- <br> and links inserted in <pre> tags HOT 9
- Static Frontpage? HOT 3
- Bug page admin + workarroud HOT 2
- Upload file size HOT 2
- error with php 7.2 HOT 5
- Still active HOT 3
- PHP 7.2+ deprecated INTL_IDNA_VARIANT_2003 in boot.php HOT 2
- Improprement on MySQL config HOT 3
- Amélioration de l'expérience avec les réglages HOT 2
- Typo in the upload image form HOT 3
- New themes HOT 2
- PHP 7.4.2 and get_magic_quotes_gpc HOT 1
- Dossiers des flux RSS en ordre DESC HOT 1
- prefixage des tables
- blogotext 3.7.6 +php 7.2, fonction idn_to_ascii()
- Trying to get in touch regarding a security issue
- Fatal error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blogotext.