Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #11884 > unrolled thread
| Started by | "James Harris" <james.harris.1@gmail.com> |
|---|---|
| First post | 2013-11-21 18:30 +0000 |
| Last post | 2013-11-23 19:21 +0000 |
| Articles | 20 on this page of 24 — 8 participants |
Back to article view | Back to comp.lang.php
PHP functions to convert markup efficiently "James Harris" <james.harris.1@gmail.com> - 2013-11-21 18:30 +0000
Re: PHP functions to convert markup efficiently The Natural Philosopher <tnp@invalid.invalid> - 2013-11-21 18:39 +0000
Re: PHP functions to convert markup efficiently "James Harris" <james.harris.1@gmail.com> - 2013-11-21 18:57 +0000
Re: PHP functions to convert markup efficiently Christoph Michael Becker <cmbecker69@arcor.de> - 2013-11-21 20:10 +0100
Re: PHP functions to convert markup efficiently "James Harris" <james.harris.1@gmail.com> - 2013-11-21 19:29 +0000
Re: PHP functions to convert markup efficiently Christoph Michael Becker <cmbecker69@arcor.de> - 2013-11-21 21:18 +0100
Re: PHP functions to convert markup efficiently Salvatore <sal@yojimbo.hack.invalid> - 2013-11-21 19:03 +0000
Re: PHP functions to convert markup efficiently Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-21 21:27 +0100
Re: PHP functions to convert markup efficiently Arno Welzel <usenet@arnowelzel.de> - 2013-11-22 11:33 +0100
Re: PHP functions to convert markup efficiently "James Harris" <james.harris.1@gmail.com> - 2013-11-22 12:48 +0000
Re: PHP functions to convert markup efficiently Jerry Stuckle <jstucklex@attglobal.net> - 2013-11-22 08:53 -0500
Re: PHP functions to convert markup efficiently "James Harris" <james.harris.1@gmail.com> - 2013-11-23 06:21 +0000
Re: PHP functions to convert markup efficiently Jerry Stuckle <jstucklex@attglobal.net> - 2013-11-23 06:59 -0500
Re: PHP functions to convert markup efficiently Christoph Michael Becker <cmbecker69@arcor.de> - 2013-11-23 13:12 +0100
Re: PHP functions to convert markup efficiently Arno Welzel <usenet@arnowelzel.de> - 2013-11-22 16:42 +0100
Re: PHP functions to convert markup efficiently "James Harris" <james.harris.1@gmail.com> - 2013-11-23 16:38 +0000
Re: PHP functions to convert markup efficiently Richard Yates <richard@yatesguitar.com> - 2013-11-23 13:24 -0800
Re: PHP functions to convert markup efficiently "James Harris" <james.harris.1@gmail.com> - 2013-11-23 22:07 +0000
Re: PHP functions to convert markup efficiently Arno Welzel <usenet@arnowelzel.de> - 2013-11-24 17:09 +0100
Re: PHP functions to convert markup efficiently "James Harris" <james.harris.1@gmail.com> - 2013-11-24 18:11 +0000
Re: PHP functions to convert markup efficiently Arno Welzel <usenet@arnowelzel.de> - 2013-11-24 23:18 +0100
Re: PHP functions to convert markup efficiently "James Harris" <james.harris.1@gmail.com> - 2013-11-24 23:44 +0000
Re: PHP functions to convert markup efficiently Arno Welzel <usenet@arnowelzel.de> - 2013-11-25 08:11 +0100
Re: PHP functions to convert markup efficiently "James Harris" <james.harris.1@gmail.com> - 2013-11-23 19:21 +0000
Page 1 of 2 [1] 2 Next page →
| From | "James Harris" <james.harris.1@gmail.com> |
|---|---|
| Date | 2013-11-21 18:30 +0000 |
| Subject | PHP functions to convert markup efficiently |
| Message-ID | <l6ljfj$fue$1@dont-email.me> |
I am looking for a way to mark up text in a way that PHP would be able to efficiently and quickly convert to HTML. I could either use an existing markup language or design a new one but I wanted to know of which PHP functions would be ideal to use to process it most efficiently. To a large extent that will guide the choice of markup tags if I have to design it myself. For example, it looks like I could choose between PHP's expand(), fgets() and regular expression handling. Of course, implemenations may differ slightly but, on average, are there certain PHP approaches that could be expected to be faster than others? What is the accepted wisdom? James
[toc] | [next] | [standalone]
| From | The Natural Philosopher <tnp@invalid.invalid> |
|---|---|
| Date | 2013-11-21 18:39 +0000 |
| Message-ID | <l6lk04$e54$1@news.albasani.net> |
| In reply to | #11884 |
On 21/11/13 18:30, James Harris wrote: > I am looking for a way to mark up text in a way that PHP would be able to > efficiently and quickly convert to HTML. > mark the text up with HTML! > I could either use an existing markup language or design a new one but I > wanted to know of which PHP functions would be ideal to use to process it > most efficiently. To a large extent that will guide the choice of markup > tags if I have to design it myself. > > For example, it looks like I could choose between PHP's expand(), fgets() > and regular expression handling. > > Of course, implemenations may differ slightly but, on average, are there > certain PHP approaches that could be expected to be faster than others? What > is the accepted wisdom? > > James > > -- Ineptocracy (in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
[toc] | [prev] | [next] | [standalone]
| From | "James Harris" <james.harris.1@gmail.com> |
|---|---|
| Date | 2013-11-21 18:57 +0000 |
| Message-ID | <l6ll1v$s43$1@dont-email.me> |
| In reply to | #11885 |
"The Natural Philosopher" <tnp@invalid.invalid> wrote in message news:l6lk04$e54$1@news.albasani.net... > On 21/11/13 18:30, James Harris wrote: >> I am looking for a way to mark up text in a way that PHP would be able to >> efficiently and quickly convert to HTML. >> > > mark the text up with HTML! No good. Too complex to vet, not secure (people other than me could add markup) and would not allow enhanced functions that I anticipate needing to add. It needs to be markup I can control. >> I could either use an existing markup language or design a new one but I >> wanted to know of which PHP functions would be ideal to use to process it >> most efficiently. To a large extent that will guide the choice of markup >> tags if I have to design it myself. >> >> For example, it looks like I could choose between PHP's expand(), fgets() >> and regular expression handling. >> >> Of course, implemenations may differ slightly but, on average, are there >> certain PHP approaches that could be expected to be faster than others? >> What >> is the accepted wisdom? James
[toc] | [prev] | [next] | [standalone]
| From | Christoph Michael Becker <cmbecker69@arcor.de> |
|---|---|
| Date | 2013-11-21 20:10 +0100 |
| Message-ID | <528e5aa6$0$6627$9b4e6d93@newsspool2.arcor-online.net> |
| In reply to | #11886 |
James Harris wrote: > "The Natural Philosopher" <tnp@invalid.invalid> wrote in message > news:l6lk04$e54$1@news.albasani.net... >> On 21/11/13 18:30, James Harris wrote: >>> I am looking for a way to mark up text in a way that PHP would be able to >>> efficiently and quickly convert to HTML. >>> >> >> mark the text up with HTML! > > No good. Too complex to vet, not secure (people other than me could add > markup) There are tools which help with this, e.g. <http://htmlpurifier.org/>. > and would not allow enhanced functions that I anticipate needing to > add. It needs to be markup I can control. Then you may consider XML. There are several libraries dealing with XML that come bundled with PHP[1]. >>> I could either use an existing markup language or design a new one but I >>> wanted to know of which PHP functions would be ideal to use to process it >>> most efficiently. To a large extent that will guide the choice of markup >>> tags if I have to design it myself. >>> >>> For example, it looks like I could choose between PHP's expand(), fgets() >>> and regular expression handling. I never heard of a PHP function called expand(). Anyway, if you want to use your own markup, regular expression are most likely the way to go, as scanning by characters might be too slow in pure PHP. >>> Of course, implemenations may differ slightly but, on average, are there >>> certain PHP approaches that could be expected to be faster than others? Most likely those which are programmed in C. [1] <http://php.net/manual/en/refs.xml.php> -- Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | "James Harris" <james.harris.1@gmail.com> |
|---|---|
| Date | 2013-11-21 19:29 +0000 |
| Message-ID | <l6lmul$888$1@dont-email.me> |
| In reply to | #11888 |
"Christoph Michael Becker" <cmbecker69@arcor.de> wrote in message news:528e5aa6$0$6627$9b4e6d93@newsspool2.arcor-online.net... ... >>>> For example, it looks like I could choose between PHP's expand(), >>>> fgets() >>>> and regular expression handling. > > I never heard of a PHP function called expand(). Oops - that should have been explode(). >>>> Of course, implemenations may differ slightly but, on average, are >>>> there >>>> certain PHP approaches that could be expected to be faster than others? > > Most likely those which are programmed in C. Is there a way to identify those? That may not be the only consideration. ISTM that even if the regular expression handler is programmed in C simple string handling (hopefully also programmed in C) should be much faster as long as it is written sensibly. James
[toc] | [prev] | [next] | [standalone]
| From | Christoph Michael Becker <cmbecker69@arcor.de> |
|---|---|
| Date | 2013-11-21 21:18 +0100 |
| Message-ID | <528e6a97$0$6633$9b4e6d93@newsspool2.arcor-online.net> |
| In reply to | #11889 |
James Harris wrote: >>>>> Of course, implemenations may differ slightly but, on average, are >>>>> >>>> there >>>>> >>>> certain PHP approaches that could be expected to be faster than others? >> > >> > Most likely those which are programmed in C. > Is there a way to identify those? The core of PHP and all bundled extensions are written in C, as well as all PECL packages. PEAR packages and many other libraries are programmed in pure PHP. > That may not be the only consideration. ISTM that even if the regular > expression handler is programmed in C simple string handling (hopefully also > programmed in C) should be much faster as long as it is written sensibly. Of course, a strpos() is faster than an respective preg_match(), but simple string functions are not as powerful as regular expressions, and so the number of times they have to be called will sum up. Scanning character by character, however, might involve a lot of conditional statements. However, the perfomance might not matter for relatively small texts at all. -- Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | Salvatore <sal@yojimbo.hack.invalid> |
|---|---|
| Date | 2013-11-21 19:03 +0000 |
| Message-ID | <l6lldu$1qhs$1@news.tokachu.com> |
| In reply to | #11884 |
On 2013-11-21, James Harris <james.harris.1@gmail.com> wrote: > I am looking for a way to mark up text in a way that PHP would be able to > efficiently and quickly convert to HTML. Have you tried Markdown? There's a PHP class that you can drop right into any project. It doesn't support images, I don't believe, but it does allow hyperlinks and basic text formatting. -- Blah blah bleh... GCS/CM d(-)@>-- s+:- !a C++$ UBL++++$ L+$ W+++$ w M++ Y++ b++
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2013-11-21 21:27 +0100 |
| Message-ID | <2142920.u9UtNiUPjK@PointedEars.de> |
| In reply to | #11884 |
James Harris wrote:
> I am looking for a way to mark up text in a way that PHP would be able to
> efficiently and quickly convert to HTML.
You are probably looking for a template engine like <http://www.smarty.net/>
then.
> […]
> For example, it looks like I could choose between PHP's expand(), fgets()
> and regular expression handling.
There is no built-in expand() function in PHP. fgets() reads files line by
line; HTML converts whitespace outside of attribute values to one space –
not what you want. Regular expressions are used for pattern matching; I do
not see how they would be applicable here.
> Of course, implemenations may differ slightly but, on average, are there
> certain PHP approaches that could be expected to be faster than others?
> What is the accepted wisdom?
Depends on what you *really* want to do.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
[toc] | [prev] | [next] | [standalone]
| From | Arno Welzel <usenet@arnowelzel.de> |
|---|---|
| Date | 2013-11-22 11:33 +0100 |
| Message-ID | <528F32EE.5030800@arnowelzel.de> |
| In reply to | #11884 |
Am 21.11.2013 19:30, schrieb James Harris: > I am looking for a way to mark up text in a way that PHP would be able to > efficiently and quickly convert to HTML. What kind of text? What kind of markup is needed? -- Arno Welzel http://arnowelzel.de http://de-rec-fahrrad.de
[toc] | [prev] | [next] | [standalone]
| From | "James Harris" <james.harris.1@gmail.com> |
|---|---|
| Date | 2013-11-22 12:48 +0000 |
| Message-ID | <l6njsf$rat$1@dont-email.me> |
| In reply to | #11911 |
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. "Arno Welzel" <usenet@arnowelzel.de> wrote in message news:528F32EE.5030800@arnowelzel.de... > Am 21.11.2013 19:30, schrieb James Harris: > >> I am looking for a way to mark up text in a way that PHP would be able to >> efficiently and quickly convert to HTML. > > What kind of text? What are the options? I was just thinking about normal text of the kind that would appear on a web page. > 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 For completeness, I should add that the markup would also need to pull in similarly marked up text from other files and to populate tables from databases. James
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2013-11-22 08:53 -0500 |
| Message-ID | <l6nnl9$g03$2@dont-email.me> |
| In reply to | #11916 |
On 11/22/2013 7:48 AM, James Harris wrote: > 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. > > "Arno Welzel" <usenet@arnowelzel.de> wrote in message > news:528F32EE.5030800@arnowelzel.de... >> Am 21.11.2013 19:30, schrieb James Harris: >> >>> I am looking for a way to mark up text in a way that PHP would be able to >>> efficiently and quickly convert to HTML. >> >> What kind of text? > > What are the options? I was just thinking about normal text of the kind that > would appear on a web page. > >> 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 > > For completeness, I should add that the markup would also need to pull in > similarly marked up text from other files and to populate tables from > databases. > > James > > So you want to make people learn another markup language which will end up being just another version of HTML? HTML is not all that complicated. It just takes a little time. Using a good validator is also helpful. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
| From | "James Harris" <james.harris.1@gmail.com> |
|---|---|
| Date | 2013-11-23 06:21 +0000 |
| Message-ID | <l6phgi$5fj$1@dont-email.me> |
| In reply to | #11921 |
"Jerry Stuckle" <jstucklex@attglobal.net> wrote in message news:l6nnl9$g03$2@dont-email.me... ... >>> 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 you want to make people learn another markup language which will end up > being just another version of HTML? No but wouldn't it be unsafe to let people to enter raw HTML? James
[toc] | [prev] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2013-11-23 06:59 -0500 |
| Message-ID | <l6q5b7$mti$1@dont-email.me> |
| In reply to | #11940 |
On 11/23/2013 1:21 AM, James Harris wrote: > "Jerry Stuckle" <jstucklex@attglobal.net> wrote in message > news:l6nnl9$g03$2@dont-email.me... > > ... > >>>> 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 you want to make people learn another markup language which will end up >> being just another version of HTML? > > No but wouldn't it be unsafe to let people to enter raw HTML? > > James > > What is unsafe about it? -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
| From | Christoph Michael Becker <cmbecker69@arcor.de> |
|---|---|
| Date | 2013-11-23 13:12 +0100 |
| Message-ID | <52909bb9$0$6565$9b4e6d93@newsspool4.arcor-online.net> |
| In reply to | #11940 |
James Harris wrote: > No but wouldn't it be unsafe to let people to enter raw HTML? At least, if you're going to let untrusted users (e.g. visitors of a publicly available site) to enter HTML, you will have to filter the HTML to avoid injection of scripts and maybe other undesired markup. HTMLPurifier does a good job here, as may do other solutions. -- Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | Arno Welzel <usenet@arnowelzel.de> |
|---|---|
| Date | 2013-11-22 16:42 +0100 |
| Message-ID | <528F7B7D.4030701@arnowelzel.de> |
| In reply to | #11916 |
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. 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.). [...] >> 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). > For completeness, I should add that the markup would also need to pull in > similarly marked up text from other files and to populate tables from > databases. This is out of scope for "markup" - but DokuWiki can handle that as well using includes - there are several plugins to include other files within a document and you can extend these plugins to use only "marked" content from a file as well. -- Arno Welzel http://arnowelzel.de http://de-rec-fahrrad.de
[toc] | [prev] | [next] | [standalone]
| From | "James Harris" <james.harris.1@gmail.com> |
|---|---|
| Date | 2013-11-23 16:38 +0000 |
| Message-ID | <l6qlml$dvj$1@dont-email.me> |
| In reply to | #11926 |
"Arno Welzel" <usenet@arnowelzel.de> wrote in message news:528F7B7D.4030701@arnowelzel.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. James
[toc] | [prev] | [next] | [standalone]
| From | Richard Yates <richard@yatesguitar.com> |
|---|---|
| Date | 2013-11-23 13:24 -0800 |
| Message-ID | <co6299tplsjmmmr0uovsldejl3431363l5@4ax.com> |
| In reply to | #11945 |
On Sat, 23 Nov 2013 16:38:45 -0000, "James Harris" <james.harris.1@gmail.com> wrote: >"Arno Welzel" <usenet@arnowelzel.de> wrote in message >news:528F7B7D.4030701@arnowelzel.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.
[toc] | [prev] | [next] | [standalone]
| From | "James Harris" <james.harris.1@gmail.com> |
|---|---|
| Date | 2013-11-23 22:07 +0000 |
| Message-ID | <l6r8va$1k2$1@dont-email.me> |
| In reply to | #11948 |
"Richard Yates" <richard@yatesguitar.com> wrote in message news:co6299tplsjmmmr0uovsldejl3431363l5@4ax.com... ... > >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? Theoretically yes but that would be hard to do and much slower. Consider that if you see <p> on a page you don't know whether it is an HTML paragraph tag or not unless you know its context. It might be part of a Java program, for example, as in f<p>(); or it could be just an insignificant piece of text that should appear as written. The only way to tell for sure is to parse the file from the top and recognise every element that precedes it. That would be a lot of work. > 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. It is possible but would require lots of parsing code. By contrast, converting markup to HTML can be made much easier. FWIW, I found I could do something that works much more simply and wrote it up in a post made just a few hours ago. James
[toc] | [prev] | [next] | [standalone]
| From | Arno Welzel <usenet@arnowelzel.de> |
|---|---|
| Date | 2013-11-24 17:09 +0100 |
| Message-ID | <529224C1.4060400@arnowelzel.de> |
| In reply to | #11945 |
James Harris, 2013-11-23 17:38: > "Arno Welzel" <usenet@arnowelzel.de> wrote in message [...] >> 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 What exactly? > take them away and to restrict the formatting it accepts. I'm not sure I You can. But you have to write a plugin to filter the markup of course. > 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. Your mileage may vary. Using just PHP itself and creating all the scripts on your own is of course the most flexible way - but I doubt if it is really "easy" if you want to create code which you still understand 2 years later ;-) -- Arno Welzel http://arnowelzel.de http://de-rec-fahrrad.de
[toc] | [prev] | [next] | [standalone]
| From | "James Harris" <james.harris.1@gmail.com> |
|---|---|
| Date | 2013-11-24 18:11 +0000 |
| Message-ID | <l6tfh2$nh3$1@dont-email.me> |
| In reply to | #11951 |
"Arno Welzel" <usenet@arnowelzel.de> wrote in message news:529224C1.4060400@arnowelzel.de... > James Harris, 2013-11-23 17:38: > >> "Arno Welzel" <usenet@arnowelzel.de> wrote in message > [...] >>> 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 > > What exactly? Would exactly would I want to prevent it doing? Unfortunately, most of it! Things like: * automatic conversion of URLs which are not marked up * automatic lowering of the case of page names * interwiki links * windows shares links * ALL of its smileys * its Usenet-style quoting * most table cell merging * embeddable HTML and PHP Sorry, but you did ask! It's not all bad. FWIW there are some things I like about it. >> take them away and to restrict the formatting it accepts. I'm not sure I > > You can. But you have to write a plugin to filter the markup of course. > >> 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. > > Your mileage may vary. > > Using just PHP itself and creating all the scripts on your own is of > course the most flexible way - but I doubt if it is really "easy" if you > want to create code which you still understand 2 years later ;-) That is possible but the code so far is tiny. Partly because it has been easy so far I am more concerned that I may have failed to consider something fundamental! James
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | comp.lang.php
csiph-web