FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » PHP functions to convert markup efficiently
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: PHP functions to convert markup efficiently [message #183879 is a reply to message #183876] Sat, 23 November 2013 21:24 Go to previous messageGo to previous message
Richard Yates is currently offline  Richard Yates
Messages: 86
Registered: September 2013
Karma:
Member
On Sat, 23 Nov 2013 16:38:45 -0000, "James Harris"
<james(dot)harris(dot)1(at)gmail(dot)com> wrote:

> "Arno Welzel" <usenet(at)arnowelzel(dot)de> wrote in message
> news:528F7B7D(dot)4030701(at)arnowelzel(dot)de...
>> Am 22.11.2013 13:48, schrieb James Harris:
>>
>>> Having looked at Markdown and Smarty that people suggested it might be
>>> better if I bite the bullet and develop my own markup language. It would
>>> then be easier both to limit what it allows and also to add features as
>>> needed. I have been running some syntax tests and it seems quite easy to
>>> do
>>> and fast to process even though the markup is currently a little
>>> cumbersome
>>> to write.
>>
>> I think this is not a good idea.
>>
>> Existing markup languages are well documented and there are existing
>> implementations to parse the markup and convert it to HTML (or other
>> formats) which are not only used by one person - so it is likely that
>> bugs will be fixed as well within a reasonable time.
>
> Noted.
>
>> Besides Markdown and Smarty you can also try DokuWiki - it's markup can
>> be extended using syntax plugins (and you can create your own plugins as
>> well to handle block level or inline elements etc.).
>
> I took a look at DokuWiki (having previously looked at the others). It's
> good but does things I don't want. At first glance I couldn't see a way to
> take them away and to restrict the formatting it accepts. I'm not sure I
> want to invest the time needed to learn any of those packages when, at least
> for now, it seems that native PHP is easy enough to use and is far more
> flexible.
>
>>>> What kind of markup is needed?
>>>
>>> Quite a lot. Things like these:
>>> * bold, italic
>>> * links to local pages and remote URLs
>>> * images, code
>>> * headers, lists, line breaks
>>> * tables
>>> * other things will likely be required but are not defined yet
>>
>> So - if HTML is to complicated you should really try DokuWiki first.
>>
>> And if even this syntax is too complicated you should not use a markup
>> language at all but a WYSWIG editor which produces valid HTML (for
>> example TinyMCE or CKEditor).
>
> I am not trying to avoid complexity. Using PHP to convert markup to HTML
> allows me to do things like these:
> * restrict the elements that can be used (for security)
> * add features such as a server-side TOC
> * pull in data from various sources
> * choose where to place elements such as footnotes
> * make each page of the site a consistent structure
>
> Basically, the combination of HTML, CSS, PHP and my own markup codes seems
> ideal. Aside from having to devise the coding the rest is completely
> standard and incredibly lightweight. As such, there will be no packages and
> associated bugfixes to install and it should be very fast.
>
> I'll keep in mind that there are prebuilt options, though, in case I run
> into difficulties as I work on this.

Can you use HTML codes, plus any markup you invent, but sanitize the
input by stripping any HTML or other tags that you do not want or that
could be a risk?

I have a page where users can enter raw MySQL queries to generate
reports. The first thng that happens to input is to check that only
SELECT queries are processed (plus a lot of other safeguards). I also
devised a 'COPY from table where index=x' command that allows copying
one record easily. So, the page uses a limited form of a standard
markup, supplemented with extras, and is completely safe.

Seems you could do the same with HTML.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: changing iframe source via php
Next Topic: converting numbers to ascii values
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 12:50:54 GMT 2024

Total time taken to generate the page: 0.04603 seconds