PmSyntax

Tests for a PmWiki syntax highlighter
This is to test Cookbook:PmSyntax (syntax highlighting only). Try the Toggle buttons!

Notes

Don't feel intimidated by the apparent complexity, in most real-world scenarios you'll have much fewer markups so close together (except probably in pagelist templates and forms which are edited rarely). In a usual situation you'll have the occasional markup stand out.

If this is bad, the same without highlighting is probably worse ;-)

and Toggle dark theme

! Page structure

(:toc:) (:notoc:)
!! Heading
!!! Subheading
!!!! Sub-subheading

----- horizontal rule

Q: Question
A: Answer

!! Basic markup
* List
* List
## Nested
## Item
   Part of "Item"
## After
   * Another kind of nested,
   * aligned to "A" above

: Term : Definition
: Term2 : Def 2
: With [=:=] colon: Definition 

    Preformatted block with
    '''leading'''    spaces

-> Indented text
------< hanging text line
!! Inline markups

'''Strong''', ''emphasis'', 
@@code@@, '-small-', '+big+'
[--smaller--], [++bigger++]

{+underlined+}, {-struck-}

'^superscript^', '_subscript_'

Join line \
  with next.

Line breaks\\
More line breaks\\\\\

[=escaped text, not processed,
 and can span multiple lines=]

[@ Another escaped  text.   
* ''Markup'' isn't processed.
@]


!!! Custom inline markups

Would need some configuration: 
'~italic~' and '*bold*'
[^footnote^] {$ formula $}

See Cookbook:CustomSyntax.

!! Links & attachments
[[Page]], [[Page|+]], [[Page|#]]
[[!Category]], [[~Profile]]

[[URL | text]], [[text->URL]]

https://bare-url.org/pathname
mailto:example@example.net

[[https://pmwiki.org|PmWiki]]

[[#anchor]]
[[#anchor|link to anchor]]

Attach:pic.jpg"Tooltip" | caption
Attach:Test./image.jpg | caption
[[Attach:recipe.zip|download]]

[[(Test.Pm)Syntax ]]test
[[(https://www.)example(.com)]]

[[Link "Tooltip title"|text]]

!! Locally enabled InterMap links
PmWiki:DocumentationIndex
Cookbook:PmSyntax

RFC:2368 (or [[RFC:2549]])
Wikipedia:Wiki_engine

Path:/resource/file.pdf

and Toggle dark theme

!! Core meta directives
(:title Syntax highlighting for PmWiki markup:)
(:description Some text:)
(:keywords Documentation, edit, help, markup:)
(:Summary: Tests for a PmWiki syntax highlighter:)

(:linebreaks:) or (:nolinebreaks:), or even (:nl:)
(:nolinkwikiwords:) or (:nospacewikiwords:)

(:comment Message to the editors:)
%comment% Message to updaters %%

(:redirect PageName#anchor status=301 from=name quiet=1:)

!!! Conditionals

(:if3 expr auth admin || auth attr || auth edit :)
[[Logout -> {$Name}?action=logout]]
(:elseif3 [ ! auth read {*$FullName} && name Group.* ] :)
Conditional
(:elseif3 date 2021-12-28..:) A (:else3:) B (:if3end:)


!!! Skin sections

(:noleft:)(:noright:)(:noaction:)(:notitle:)(:noheader:)
(:nofooter:), (:nogroupheader:)(:nogroupfooter:)


!!! Page text variables

Property: Start of line text variable
:Another: Variable in definition list

(:MyVariable:Some value:) or (:EmptyValue::)
(:Multiline:Variable
  can have line 
  breaks           :)

Print out variables: {$FullName}, {*$Title}, {*$:Summary}
{{*$Name}$:Summary} {Group.OtherPage$Title}

In Pagelist templates: {=$Group},  {<$Group},  {>$Group}

In templates and included sections: {$$variable}

(:include {*$FullName}-Users#fromanchor#toanchor \
 lines=12..34 self=0 basepage=abc variable=value :)
!! [[WikiStyles]]
%blue% some text%%

%apply=block color=red% Some text

%define=mystyle apply=p \
  border="2px dotted green"%

>>frame bgcolor=yellow<<
Text
>><<

%newwin% [[Link]] %%

* item %list classname id=ul2%
* item %item comment%
## %ALPHA% A
## B
## C %value=6%

!!! Some PHP and CSS code
See [[WikiStyles#highlight]]
%hlt php% [@
  # only geeks allowed
  if(!isset($EnableGeek)) exit;
@]
%hlt css% [@
/* only ants can read */
body, body * {
  font-size: 1px !important;
}@]


!! Blocks, advanced tables

(:div3 class=myblock:)
(:section id=mysection:)
text
(:sectionend:)
(:div3end:)

(:details open=open \
 summary="Toggle section...":)
Some text
(:detailsend:)

(:table class=t1 border=1:)
(:cell colspan=2:) H
(:tableend:)

and Toggle dark theme

!! Pagelists and templates

(:pagelist group={*$Group} count=5..10 fmt=#template:)

(:pagelist $:Summary=?* $Title=A* if="auth read {=$Name}":)

(:searchbox group=PmWiki label="Search documentation":)

!! Pagelists templates
[[#template]]
(:template defaults name=value group=Main order=name:)
(:template first:)
Pages in the list:
(:template each {=$Group}:)
'''{=$Group}:'''
(:template each:)
* [[{=$FullName}| {=$Title} ]] modified {=$LastModified}
(:template last:)
Displayed {$$PageCount} pages
(:template none:)
No pages found.
[[#templateend]]
!! Simple tables

|| border=1 class="sortable"
||!  Table caption  !||
||! head   ||! head  ||
||  cell   ||  cell  ||
|| ''double'' cell ||||


!! Markup expressions

{(ftime fmt="%a %d %b, %Y")}
{(strlen "PmWiki")}
{(tolower (substr "PmWiki" 2))}
{(asspaced {*$FullName})}


!! Internationalization

Click $[Edit] to modify the page,
or $[History] to see old versions.
$[Password required]
$[Editing {*$FullName}]

and Toggle dark theme

!! Forms
(:input form action=https://example.com/path/ method=post:)
(:input text name=name value=value id=identifier:)
(:input email authid placeholder="Your email" size=40:)
(:input password authpw required=required:)
(:input textarea name=area value=[=multi-
  line
  content=] cols=80 rows=3:)
(:input checkbox name=accept_terms value=yes \
  label="I accept the terms" required=required:)

(:input default source={*$FullName}:)
(:input default request=1:)
(:input text name=$:DataInPTV disabled=disabled:)
(:input submit post "Okay":)
(:input end:)

Also (:input e_form ...:), (:input e_author ...:), 
(:input e_savedraftbutton:), ..., (:input captcha:), 
(:input pmform ...:) and (:pmform target=target:)
!! Other core markup
(:messages:)

(:attachlist names=*.jpg:)

<<|[[Trail]]|>> linear trail

^|[[Trail]]|^ breadcrumb trail
(:markup class=horiz:)
[=
Markup demonstration
=]
(:markup class=norender:)
* Other markup example
(:markupend:)

Signatures ~~~ and ~~~~
(while editing, before being expanded)

Markup from cookbook recipes

How to add your custom markup to PmSyntax, see Cookbook:CustomSyntax.

Many directives defined in Cookbook recipes will be tentatively highlighted, for example:

(:any-directive Some text:)

(:anotherdirective "Some text" attribute="some value" \
  argument=anything:)

Popular recipes and Toggle dark theme

See also: Category.PmSyntax.

(:fox cbox put=below mark=!!Comments template=Site.FoxCommentTemplate:)


(:toggle hide box1 button=1:)
(:toggle id="line2" id2="line1" group="lines" init=hide show="show line 2" hide="hide line 2":)


(:attachtable filter=xxx sort=name show=mimetype:)


(:includesection "#blog-summary-pagelist blogid=blog1 status=publish":)


(:thumblist Group.Page px=128 cols=4 name="paris_*":)
(:thumbgallery cols=3 tlmode=1:)
pic1.jpg | Caption
pic2.jpg | Another caption
(:thumbgalleryend:)
(:thumb Group.Page/pic3.jpeg titlemft="click thru for larger image" captionfmt="watch this space" :)


(:pmcal styles=PmCal-Mini monthsback=1 monthsahead=2 includes=false:)


(:mini m1=128x128 m2=200x200:)

(:source lang=css header="$HTMLStylesFmt['sourceblock'] = '" footer="';":) [=
.sourceblocklink {
  text-align: right;
  font-size: smaller;
=]


(:autosections:), (:nosectionsinincludes:), (:nohorzsections:)

{(wordcount "this is a string")}
{(plist Cookbook.* -Cookbook.*Skin*)}

{(extract Term1 -Term2 ... name=PageName group=GroupName \
        keyword=value keyword2=value2 ...)}

(:galleria option_name="STRING" :) 

(:case-correction:)

{$TotalCount}, {$PageCount}, {$PageViews}

etc...

Actual snippet from a custom menu and Toggle dark theme

Contains conditionals, form elements with attributes and values, wikistyles, page variables, page text variables, and custom Markup Expressions nested in the form values.

(:if33 expr enabled EnableWorse && ! name SideBar,RecentChanges,GroupAttributes:)
* %item padding="1mm 4mm"% (:input default source={*$FullName}:) \
  (:input checkbox id=m_chk label="Page maintainer":) \
  %id=m_claim%claim%% %id=m_clear%clear%%\\
  (:input text $:MaintainerName placeholder="Maintainer name" \
    data-me="{(userdata $real_name)}" id=MaintainerName:)\\
  (:input text $:MaintainerEmail placeholder="Maintainer email" \
    size=14 data-me="{(userdata $email)}" id=MaintainerEmail:)\
  (:input button setmainainer Save id=savemaintainer:)
* [[{*$FullName}#deletepage"Delete page and all history"|Delete page]] %item color=red%
(:if33end:)

(Looking at this I think it would have been wiser to write a custom directive, but this is an old website built gradually with small additions over the years. --Petko)

 0: 00.00 00.00 config start
 1: 00.01 00.01 config end
 2: 00.22 00.21 MarkupToHTML begin
 3: 00.22 00.21 MarkupToHTML begin
 4: 00.23 00.22 MarkupToHTML end
 5: 00.25 00.24 MarkupToHTML end
 6: 00.26 00.24 MarkupToHTML begin
 7: 00.27 00.25 ReadApprovedUrls SiteAdmin.ApprovedUrls begin
 8: 00.27 00.25 ReadApprovedUrls SiteAdmin.ApprovedUrls end
 9: 00.28 00.26 MarkupToHTML end
10: 00.28 00.26 MarkupToHTML begin
11: 00.28 00.26 MarkupToHTML end
12: 00.28 00.27 now
Peak memory: 3,819,800 bytes