Advertisement
Guest User

Untitled

a guest
Jan 27th, 2021
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. // The Rolecard Builder will transform each line in the rolecard into an HTML tag, and you can style it as needed.
  2. // A style is a JSON array of "rules", achieving just that.
  3.  
  4. // Each Rule performs an action, being either "transform" or "block".
  5. // * Transform rules specify a "search & replace" call, per JS String.replace on that line.
  6. // You need to specify a "search" and "replace" field, matching what to search for, and what to replace it with.
  7. // * Block rules transform a line, and every line indented under it, into an HTML block.
  8. // You need to specify a "regex" matching the line, and optionally a "replace" on what to replace it with.
  9. // You can specify "style", "onmouseover", "onmouseout" and "onclick" attributes of the generated HTML block.
  10.  
  11. [
  12. // ###
  13. // Builds a big visible box holding a rolecard. Rolecards should be no more than 700 pixels wide.
  14. {
  15. "action": "block",
  16. "regex": "^###(.*)",
  17. "replace": "$1",
  18. "style": "width: 670px; border: 1px solid black; background-color: #D3D3FC; padding: 15px; box-shadow: 2px 2px #bab1bf; background-image: url(http://www.pvv.org/~andreasd/mafia/rolecard_builder2/bokeh.png)",
  19. "onmouseover": "this.style.backgroundColor='#E3E3FE';",
  20. "onmouseout": "this.style.backgroundColor='#D3D3FC';"
  21. },
  22.  
  23. {
  24. "action": "transform",
  25. "search": "\[RIGHT:(\S*\.png|\S*\.jpg),(\S*),(\S*)\]",
  26. "replace": "<u style='display:inline-block; float: right; background-image: url($1); width:$2px; height:$3px'></u>" // this works!
  27. },
  28.  
  29. {
  30. "action": "transform",
  31. "search": "\[LEFT:(\S*\.png|\S*\.jpg),(\S*),(\S*)\]",
  32. "replace": "<u style='display:inline-block; float: left; background-image: url($1); width:$2px; height:$3px'></u>" // this works!
  33. },
  34.  
  35. // [image_url,width,height]
  36. // Replaces an image URL in brackets with an image tag
  37. // Unfortunately, QT doesn't support IMG tags, so we have to improvise.
  38. // --- An image at the start of the line turns into a "bullet section".
  39. {
  40. "action": "block",
  41. "regex": "^\[(\S*\.png|\S*\.jpg),(\S*),(\S*)\] (.*)",
  42. "replace": "<u style='position: absolute; display:inline-block; background-image: url($1); left: calc(-$2px - 10px); width:$2px; height:$3px'></u>$4", // this works!
  43. "style": "position: relative; margin-left: calc($2px + 10px); min-height: $2px); margin-bottom: 15px"
  44. },
  45. { // --- Whereas other blocks just turn into inline images.
  46. "action": "transform",
  47. "search": "\[(\S*\.png|\S*\.jpg),(\S*),(\S*)\]",
  48. "replace": "<u style='display:inline-block; background-image: url($1); width:$2px; height:$3px'></u>" // this works!
  49. },
  50.  
  51. // === Small Heading ===
  52. // Headline, sectioned by a margin. All text under it will be indented a bit.
  53. {
  54. "action": "block",
  55. "regex": "===(.*)===(.*)",
  56. "replace": "<b style='font-size: 130%; display:block; margin: 0 0 1em -20px'>$1</b>$2",
  57. "style": "padding: 0 0 15px 20px"
  58. },
  59.  
  60. // === Large Heading ===
  61. // Headline, sectioned by a margin. All text under it will be indented a bit.
  62. {
  63. "action": "block",
  64. "regex": "==(.*)==(.*)",
  65. "replace": "<b style='font-size: 160%; display:block; margin: 0 0 1em -20px'>$1</b>$2",
  66. "style": "padding: 0 0 15px 20px"
  67. },
  68.  
  69. // *Bold Text*
  70. // Text immediately inbetween stars turn bold.
  71. {
  72. "action": "transform",
  73. "search": "\*(\S[^*]*\S)\*",
  74. "replace": "<b>$1</b>"
  75. }
  76. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement