Advertisement
krusader74

Sample Markdown2BBCode Document

Jan 26th, 2016
397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.79 KB | None | 0 0
  1. %YAML 1.2
  2. ---
  3. Title: Sample Markdown2BBCode Document
  4. Author: Krusader74
  5. # This is a YAML comment, not a Markdown header
  6. # YAML uses the ISO-8601 standard to express dates:
  7. Date: 2016-01-25T14:25:54-0500
  8. note: >-
  9. This is a note intended to demonstrate
  10. metadata that spans multiple lines, yet
  11. is treated as a single value.
  12. foo: bar
  13. calc: log(exp(1))+2+3+2*2
  14. ...
  15.  
  16. This file illustrates some of the capabilities of the [Markdown2BBCode.pl](http://pastebin.com/dqnHKAe6) Perl script.
  17.  
  18. First of all, you can see above that we allow an optional block of [YAML](http://yaml.org/) Metadata at the top. The first line with the YAML version number is optional. YAML goes between a line with three dashes and a line with three dots. You can refer to the metadata later in your Mardown like this:
  19.  
  20. The foo variable is [%foo].
  21.  
  22. BLOCK ELEMENTS
  23. ==============
  24.  
  25. atx-style headers...
  26.  
  27. # Heading 1
  28. ## Heading 2
  29. ### Heading 3
  30. #### Heading 4
  31. ##### Heading 5
  32. ###### Heading 6
  33.  
  34. # Heading 1 #
  35. ## Heading 2 ##
  36.  
  37. Setext-style headers...
  38.  
  39. Heading 1
  40. =========
  41.  
  42. Heading 2
  43. ---------
  44.  
  45. Blockquotes...
  46.  
  47. > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
  48. > consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
  49. > Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
  50. >
  51. > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
  52. > id sem consectetuer libero luctus adipiscing.
  53.  
  54. Nested blockquotes...
  55.  
  56. > This is the first level of quoting.
  57. >
  58. > > This is nested blockquote.
  59. >
  60. > Back to the first level.
  61.  
  62. Blockquotes with formatting inside...
  63.  
  64. > ## This is a header.
  65. >
  66. > 1. This is the **first** list item.
  67. > 2. This is the _second_ list item.
  68. >
  69. > Here's some example code:
  70. >
  71. > return shell_exec("echo $input | $markdown_script");
  72.  
  73. Lists...
  74.  
  75. Numbered list...
  76.  
  77. 3. Bird
  78. 1. McHale
  79. 8. Parish
  80.  
  81. Bullet list...
  82.  
  83. * Red
  84. * Green
  85. * Blue
  86.  
  87. List items with paragraphs...
  88.  
  89. 1. This is a list item with two paragraphs. Lorem ipsum dolor
  90. sit amet, consectetuer adipiscing elit. Aliquam hendrerit
  91. mi posuere lectus.
  92.  
  93. Vestibulum enim wisi, viverra nec, fringilla in, laoreet
  94. vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
  95. sit amet velit.
  96.  
  97. 2. Suspendisse id sem consectetuer libero luctus adipiscing.
  98.  
  99. A list item with embedded quotes...
  100.  
  101. * A list item with a blockquote:
  102.  
  103. > This is a blockquote
  104. > inside a list item.
  105.  
  106. This is a normal paragraph:
  107.  
  108. This is a code block indented by at least 4 spaces or 1 tab
  109.  
  110. ```
  111. This is a fenced code block
  112. ```
  113.  
  114. Inline BBCode...
  115.  
  116. [table]
  117. [tr]
  118. [td]Foo[/td]
  119. [/tr]
  120. [/table]
  121.  
  122. HTML comments are not output to the resulting BBBcode...
  123. <!-- Regular HTML comment -->
  124.  
  125. Tables...
  126.  
  127. Colons can be used to align columns.
  128.  
  129. | Tables | Are | Cool |
  130. | ------------- |:-------------:| -----:|
  131. | col 3 is | right-aligned | $1600 |
  132. | col 2 is | centered | $12 |
  133. | zebra stripes | are neat | $1 |
  134.  
  135. There must be at least 3 dashes separating each header cell.
  136. The outer pipes (|) are optional, and you don't need to make the
  137. raw Markdown line up prettily. You can also use inline Markdown.
  138.  
  139. Markdown | Less | Pretty
  140. --- | --- | ---
  141. *Still* | `renders` | **nicely**
  142. 1 | 2 | 3
  143.  
  144. Horizontal rules...
  145.  
  146. * * *
  147.  
  148. ***
  149.  
  150. *****
  151.  
  152. - - -
  153.  
  154. ---------------------------------------
  155.  
  156. SPAN ELEMENTS
  157. =============
  158.  
  159. Links
  160. -----
  161.  
  162. This is [an example](http://example.com/ "Title") inline link.
  163.  
  164. This is [an example][id] reference-style link.
  165.  
  166. [id]: http://example.com/ "Optional Title Here"
  167.  
  168. Implicit link name shortcuts...
  169.  
  170. [Google][]
  171.  
  172. [Google]: http://google.com/
  173.  
  174. Images...
  175.  
  176. ![Alt text](/path/to/img.jpg)
  177.  
  178. ![Alt text](/path/to/img.jpg "Optional title")
  179.  
  180. Footnotes...
  181.  
  182. Here is some text containing a footnote.[^somesamplefootnote]
  183.  
  184. [^somesamplefootnote]: Here is the text of the footnote itself.
  185.  
  186. Footnotes can contain block-level elements, which means that you can put multiple paragraphs, lists, blockquotes and so on in a footnote.[^1]
  187.  
  188. [^1]: And that's the footnote.
  189.  
  190. That's the *second* paragraph.
  191.  
  192. - item foo
  193. - item bar
  194. - item baz
  195.  
  196. > And a quote too.
  197.  
  198. Emphasis
  199. --------
  200.  
  201. **This text is bold.**
  202.  
  203. _This text is italic._
  204.  
  205. *This text is italic too.*
  206.  
  207. Non-standard markups... Syntactic sugar for your BBCode...
  208.  
  209. __This text is underlined.__
  210.  
  211. The following word has a ~~strikethrough~~.
  212.  
  213. ^^This text is BIG.^^
  214.  
  215. Superscript: E = m c^2^
  216.  
  217. Subscript: H~2~O
  218.  
  219. Math
  220. ----
  221.  
  222. LaTeX math commands between dollar signs like $e^{i \pi} + 1 = 0$ and $\nabla\times H = J + \frac{\partial D}{\partial t}$ will get converted to Unicode as best as possible.
  223.  
  224. If you're not doing math, escape a dollar sign with a slash. For example, this is not math, just US money: \$1.50
  225.  
  226. A list of math...
  227.  
  228. * square root of two: $\sqrt{2}$
  229. * Pythagorean theorem: $c = \sqrt{a^2 + b^2}$
  230. * the circumference of a circle: $2 \pi r$
  231. * Strength: $\dice{iii}\dice{iv}\dice{ii} = 9$
  232. * Einstein Field Equations: $G_{\mu \nu} + \Lambda g_{\mu \nu} = \frac{8 \pi G}{c^4} T_{\mu \nu}$
  233.  
  234. A table of the [Hypercomplex numbers](https://en.wikipedia.org/wiki/Hypercomplex_number) and their algebraic properties...
  235.  
  236. \# = basis elems | Set | [Ordering?](https://en.wikipedia.org/wiki/Ordered_field) | [Commutative?](https://en.wikipedia.org/wiki/Commutative_property) | [Associative?](https://en.wikipedia.org/wiki/Associative_property) | [Alternative?](https://en.wikipedia.org/wiki/Alternative_algebra)
  237. -------------------------|--------------------------|-----------|--------------|--------------|-------------
  238. $1 = |\{ 1 \}|$ | Reals $\mathbb{R}$ | Yes | Yes | Yes | Yes
  239. $2 = |\{ 1, i \} |$ | Complex $\mathbb{C}$ | No | Yes | Yes | Yes
  240. $4 = |\{ 1, i, j, k \}|$ | Quaternions $\mathbb{H}$ | No | No | Yes | Yes
  241. $8 = |\{e_i |i=0..7\}|$ | Octonians | No | No | No | Yes
  242. $16 = |\{e_i |i=0..15\}|$| Sedonions | No | No | No | No
  243.  
  244. At-commands
  245. -----------
  246.  
  247. At-commands are a shorthand so I don't need to write BBCode tags twice (beginning/end) or do some other mundane processing...
  248.  
  249. Embed a cute cat video from YouTube...
  250. @[youtube](0Bmhjf0rKe8)
  251.  
  252. Embed an image from Imgur. It's easy enough to customize the script to create shortcuts to other photo sharing services. I just happen to use Imgur...
  253. @[imgur](Hl6gbeN.png)
  254.  
  255. Embed a tweet from Twitter...
  256. @[tweet](690183359117467648)
  257.  
  258. Scroll the text to the left...
  259. @[marquee](I'm a marquee scrolling left at speed 2!)
  260.  
  261. Do some basic arithmetic...
  262. log(exp(1))+2+3+2*2 = @[eval](log(exp(1))+2+3+2*2)
  263.  
  264. Same calculation, but now the aritmetic expression is in a metadata variable...
  265. [%calc] = @[eval]([%calc])
  266.  
  267. Note: If you want to use trig constants or functions, then add the line `use Math::Trig;` near the top of the script. Likewise, If you want to do [DateTime](http://search.cpan.org/~drolsky/DateTime-1.21/lib/DateTime.pm) arithmetic, [Statistics](http://search.cpan.org/~shlomif/Statistics-Descriptive-3.0612/lib/Statistics/Descriptive.pm), [Chi Square](http://search.cpan.org/~dcantrell/Statistics-ChiSquare-0.6/lib/Statistics/ChiSquare.pm) tests, generate variates from specific [Random](http://search.cpan.org/~grommel/Math-Random-0.70/Random.pm) distributions, etc., then just `use` the appropriate module!
  268.  
  269. Roll some dice to make a new character...
  270.  
  271. Ability | Score
  272. :------------|------------:
  273. Strength | @[roll](3d6)
  274. Intelligence | @[roll](3d6)
  275. Wisdom | @[roll](3d6)
  276. Dexterity | @[roll](3d6)
  277. Constitution | @[roll](3d6)
  278. Charisma | @[roll](3d6)
  279. Gold | @[eval](10*roll("3d6"))
  280.  
  281. Align the text...
  282. @[left](This text is on the left.)
  283.  
  284. @[right](This text is on the right.)
  285.  
  286. @[center](This text is centered.)
  287.  
  288. The following text is justified...
  289. @[justify](Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus tincidunt orci lorem, ac consequat magna vulputate at. Duis lacinia velit non massa porttitor, a porta nisi dignissim. Nulla scelerisque, augue ut porttitor commodo, lectus ex tempor nibh, quis venenatis neque ex ac ex. Suspendisse potenti. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum nibh urna, condimentum nec facilisis et, tempor id enim. Sed ac nibh ut sem auctor feugiat. Pellentesque malesuada lectus volutpat vehicula mattis. Praesent vitae imperdiet leo. Vivamus ornare et ante ac malesuada. Vestibulum leo mi, vestibulum quis purus vel, scelerisque finibus magna. Duis finibus sollicitudin augue, et consequat arcu aliquam a.)
  290.  
  291. BBCode noparse command protects any text we don't want BBCode altering...
  292. @[noparse](Create a spoiler in BBCode like this: [spoilers]Stuff that will spoil the *Sixth Sense*.[/spoilers])
  293.  
  294. Spoilers...
  295. @[spoilers](Bruce Willis was dead the whole time!)
  296.  
  297. Automatically reverse your text...
  298. @[reverse](Bruce Willis was dead the whole time!)
  299.  
  300. Do rot13 encryption...
  301. @[rot13](Bruce Willis was dead the whole time!)
  302.  
  303. At commands nest...
  304. @[reverse](@[rot13](Bruce Willis was dead the *whole* time!))
  305.  
  306. Protect Markdown text we don't want interpolated...
  307. @[nomarkdown](@[reverse](@[rot13](Bruce Willis was dead the *whole* time!)))
  308.  
  309. Comments don't show up in the output...
  310. @[comment](An alternative to HTML comments like <!-- this -->)
  311.  
  312. Highlight the text...
  313. @[hi](This text is highlighted.)
  314.  
  315. Try to hide the text by making the foreground and background colors the same (only works in the default theme)...
  316. @[hide](The foreground color is set to efefef.)
  317.  
  318. Shrink the text...
  319. @[small](This text is small!)
  320. @[smaller](This text is really small!)
  321. @[smallest](This text is really, really small!)
  322.  
  323. <!-- There's also commands for big, bigger, biggest -->
  324.  
  325. Syntax shortcuts for the seven colors of the rainbow...
  326.  
  327. > @[red](Red) @[yellow](and yellow) @[pink](and pink) @[green](and green,)
  328. > @[purple](Purple) @[orange](and orange) @[blue](and blue.)
  329. > I can sing a rainbow,
  330. > Sing a rainbow,
  331. > You can sing one too!
  332. > -- Arthur Hamilton
  333. > -- "I Can Sing a Rainbow"
  334.  
  335. Insert a Markdown file here and then process it...
  336. @[include](includeme.md)
  337.  
  338. Process a file with Markdown2BBC.pl and then insert it here...
  339. @[process](includeme.md)
  340.  
  341. Other standard BBCode tags and custom Markdown should work just fine with these at-command shorthands, but please use the custom Markdown above instead because it's more concise and elegant...
  342.  
  343. @[u](This text is underlined) ...versus... __This text is underlined__
  344.  
  345. The following word has a @[s](strikethrough) ...versus... The following word has a ~~strikethrough~~
  346.  
  347. @[big](This text is BIG) ...versus... ^^This text is BIG^^
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement