Rod's 'Drop-In' Markdown Notebook

Show off your RPG maps, campaigns, and tokens. Share your gaming experiences and stories under General Discussion and save this forum for things you've created that may help others run their own games. Use the subforums when appropriate.

Moderators: Azhrei, dorpond, trevor, Gamerdude

User avatar
rtakehara
Cave Troll
Posts: 37
Joined: Mon Nov 11, 2019 5:11 pm
Contact:

Rod's 'Drop-In' Markdown Notebook

Post by rtakehara »

What is it

This is a Notebook that supports Markdown syntax for quick and easy note taking, since its just a notebook, it is system agnostic.

Currently it supports:

-Most of Markdown basic syntax
-Markdown tables
-Link to other macros (with arguments)
-Link to image:tokens
-Link to sharing a section or a handout
-CSS Themes

Getting Started

To use it, drag and drop in any map and drag the "Notebooks" macro to the Campaign, GM or Global frames, to create new notebooks, select an empty token and open the dragged Notebooks macro, then click New Notebook. The new notebook token will have a macro to open the index and you can start using. All notebooks will show up in the Notebooks popup window if you are the GM, or all owned by you or everyone if you are a Player.

Download

Current version: 2.4.3
Github

Old version: 1.22.2
Spoiler

Getting Started

To use it, drag and drop in any map and click the "Setup" macro, it will create a new macro with the name of the Notebook (Notebook by default), use this Macro to open the notebook's index menu.

If you move the token to another map or change it's name, click setup again and it will create a new updated macro. The macro created can be dragged to the campaign, gm or any macro window really, and be accessed anywhere.

Note: For now, it doen't suport spaces in the token name. You can, however, rename the The Title Macro with spaces.

One Drive Link
Dropbox Link

Screenshots
1.png
1.png (571.16 KiB) Viewed 765 times
Now with themes! From left to right: MapTool, MT Dark, D&D, Cyberpunk
2.png
2.png (809.88 KiB) Viewed 1021 times
Left: What you see
Right: what you get
3.png
3.png (74.35 KiB) Viewed 765 times
Build in dice calculator.
4.png
4.png (401.48 KiB) Viewed 1021 times
A couple more screenshots: A Character Statblock and An Adventure Module
5.png
5.png (3.76 MiB) Viewed 1009 times
Shared Image



Updates

25/05/2020: Reworked on everything, now available in github
29/11/2019: Posted more Relevant Screenshots and added a Dropbox Link
30/11/2019: Changed how sharing sections work, and added support to sharing images. Also fixed some of the Markdown syntax.
31/11/2019: Added option to close shared windows remotely, Import/Export, and an UI to accompany these changes, also minor bug fixes.
4/12/2019: Added a dice roller/calculator that deals with dice rolls, also a lot of improvements to the Markdown syntax, lists and block quotes support 1 nested level and images support alt text, added a new type of code block that ignores formatting and a in line code that does the same, it also supports MapTool functions now and HTML is now more reliable.
5/12/2019: Small syntax improvements and fixes, added support for remote Lib:Tokens as notebooks, added a new interface for options, added 4 themes.
5/12/2019: Changed how the index searches for chapters, now it finds any heading 1 and 2, since a few macros with a lot of text perform better than a lot of macros with fewer text.
10/12/2019: started recording versions, changed cyberpunk skin with github skin, it looks better
Last edited by rtakehara on Mon May 25, 2020 9:43 pm, edited 13 times in total.

User avatar
wolph42
Deity
Posts: 9708
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Rod's 'Drop-In' Markdown Notebook

Post by wolph42 »

Nice! Thank you for sharing. When reading it something popped to mind giving me a deja vu regarding to the first time I posted the first version of the bag of tricks:

Can you do tables with it?

those are always bloody annoying to get right in html.

(and in case you're wondering about the deja vu and whether it has anything to do with tables, it doesn't, it concerns this post: http://forums.rptools.net/viewtopic.php ... 4c#p170980 which was the first respons to my post...)

User avatar
rtakehara
Cave Troll
Posts: 37
Joined: Mon Nov 11, 2019 5:11 pm
Contact:

Re: Rod's 'Drop-In' Markdown Notebook

Post by rtakehara »

wolph42 wrote:
Fri Nov 29, 2019 3:27 am
Nice! Thank you for sharing. When reading it something popped to mind giving me a deja vu regarding to the first time I posted the first version of the bag of tricks:
Very minimalistic trap, i like it.
wolph42 wrote:
Fri Nov 29, 2019 3:27 am
Can you do tables with it?

those are always bloody annoying to get right in html.
Yes it can! So far it doesn't support alignment, but once I get other more important features implemented (like sharing images, and maybe tables, and a theme selector because I've been learning css and if I don't do it first I will forget how to do it so thats more importanter), I will add it.


User avatar
wolph42
Deity
Posts: 9708
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Rod's 'Drop-In' Markdown Notebook

Post by wolph42 »

ok. I thought it to be nice to move the BoT manual to markdown and started working on this but hit a couple of snags.:

1. I can't seem to implement images from tables (or any other source), currently using this:
<img src='"+tableImage('tbl_Image',26)+"' alt='Nildiks Room Description'>

2. I can't seem to use sublists, so e.g. 3 items where the 2nd item has 4 sublist items.
Is that my lack of RTFM or are those not present?

3. If I just place this in a macro:

Code: Select all

##### Table
| Header 1 | Header 2 |
|---------|---------|
| Row 1    | Item 1   |
| Row 2    | Item 2   |
| Row 3    | Item 3   |
I get everything on one line.
edit: it appears that if I add some text AFTER the table, it works. So you can't end with a table.

4. also is there a way to use colspan ? so one text spread over multiple columns?

5. similar issue with the tickmarks. e.g. this:

Code: Select all

bla

``` These functions  ```

bla
is not working
edit: two issues with that: 1. the tickmarks apparently have to be on a separate line and 2. a space " " after the tickmarks (on the same line) makes them fail too.
edit2: this however is also not working, can't figure out why:

Code: Select all

```
These functions you call to turn the specific functionality on or off. By default it applies to the selected token(s), optionally you can give a list of token as argument. When you run the macro from the campaign panel it will run for all selected tokens. All detection macros (see/purge/annul) require a *Range* property. If the property is not set (or not numerical) the the *turn on* macros will show an input pop-up asking for these values. The values entered need to be numerical (e.g. 30).
```
6. also in that regard, it would be nice if you could check for both this ` tickmark and this ' tickmark. Reason is that in notepad, where I usually work the tickmark on the keyboard is ' instead of ` (while in Maptool its ` instead of ')

7. I'm also missing underline, is that correct?

8. a new line after bold text e.g.:

Code: Select all

**Step 1: Define Area**
What needs to be done is to get cell coordinates inside a json array. To do this there are 2 methods: lastPath and getTokens.
does NOT result in a new line, the 'what needs..' is placed directly after 'Area'. Apparently it 'eats' a new line. Cause if I do this

Code: Select all

**Step 1: Define Area**

What needs to be done is to get cell coordinates inside a json array. To do this there are 2 methods: lastPath and getTokens.
then one linebreak is removed.

8a. Same for italic

9. it appears that () in the title breaks the tile. This:

Code: Select all

#### EMBARKATION (VEHICLES)
does not work!

10. another issue I found is with ":" that character too eats a linebreak e.g.

Code: Select all

Here the full workings of the required functions and what needs to be done:
SETTINGS:
In the settings under the toggle tab you can find:
**Invisibility**: check this to make use of this functionality
will all be placed in one line.

11. similar to the * list, it would be nice to have the same with numbers e.g.:
1. bla
2. bla
3a. bla
3b. bla
4. bla
(or is this again a matter of RTFM?)

12. this line:

Code: Select all

*Script/Code functions (these only work for the 'Bag of Tricks' Tables, stored on lib:EventMacros, i.o.w. created by using the above macros):*
does not end up in italic.

=================
thats it for now. If you want to do some heavy testing :D
here's the original BoT Manual in html (with some table references and some functions)
Manual original version.txt
(75.69 KiB) Downloaded 17 times
and here's how far i got with 'marking it down'
Manual markdown version.txt
(71.59 KiB) Downloaded 11 times

User avatar
rtakehara
Cave Troll
Posts: 37
Joined: Mon Nov 11, 2019 5:11 pm
Contact:

Re: Rod's 'Drop-In' Markdown Notebook

Post by rtakehara »

Holy... That's some serious testing you did! I gave a quick look and will look deeper into this later, but for now, here's what I found:

1 and 2. What are sublists? what are images from tables? who are you? who am I? what is life? just kidding...

I don't know how this works, but I will check into it, and probably make a more reliable HTML support (for now, the converter is very destructive, it may think <html> tags are > blockquotes)

3. I think a lot of markdown syntax requires a blank line between elements (tables, horizontal rulers, blockquotes, codeblocks, paragraphs, headers...). Even if they work without space, there should be one. You dont need to add text to the end of the table, you could just add a new line (another one, I mean. I think maptools reads the end of the string as an element, so, one blank line, and one "end of string" line)

4. No. For more complex tables, I should implement a better HTML support, it suports SOME html, but its finicky

5. triple backticks are for multi line code (this is a Markdown standard), one backtick is for for in line code (by Markdown standards) but I didn't implement it because I didn't intent it to display code so I didn't want to spend the energy, I will fix that if I can.

The second code didn't work because somehow, parentheses are breaking it, I will fix it ASAP

6. Isn't wait, this ' an apostrophe? wouln't it break like, a lot of things? Maptools constantly give me some errors and when find what was the problem, 50% of the time is because there was a ' and MT is not in the mood for ' today. The other 50% is because it doesn't wanna deal with spaces.

7, 8 and 8a. Underlines are also used for __Bold__ and _italic_, you can escape the character by adding a backlash \_, its a Markdown standard

Line breaks are a similar case of "its not a bug, its a feature", any single line break is ignored, to add a line break, add two spaces at the end of a line, thats also Markdown standard, RTFM

9. Same problem as 5, parentheses are breaking a lot of things, i will fix it

10. same problem as 7 and 8

11. I am not sure it is supported by regular markdown. Probably not, what I DO know is that markdown supports nested lists and my token doesn't. It is probably possible and I might implement it, I didn't because I don't see many nested lists in RPGs (or I used this as an excuse to be lazy)

12. Parentheses again? noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo!!!1!one!!
==========================================================
edit: Html seems to be working fine, at least for images and tables, if you wanna do something more complex or something that isn't working, html should solve it (at least for tables).
Also, fixed the parentheses issues. Will do some testing and upload, latest version also will support import/export from/to markdown, so migrating should be painless (but not completely...)

User avatar
wolph42
Deity
Posts: 9708
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Rod's 'Drop-In' Markdown Notebook

Post by wolph42 »

k some response:
Sublist (edit: 'nested lists' thus...)
  • first
  • second
  • third:
    • one
    • two
    • three
  • fourth
images from tables: in maptool you can add images to the maptool tables and retrieve them.

3. no, just adding a new line below the table does NOT work.

5. I think you misunderstood: your syntax is not working, I gave some examples.

6. yes you're completely right, you could consider running a regex over the text replacing all ' with `

7.again a miscommunication: I mean underline make up of the text, like: bold, italic, underline. "_" is called "underscore" not underline.

11. ah yeah "nested lists" that's the work I was looking for when I said "sub lists".

New: apparently its not possible to escape the pipe character: "|".

one more thing:
might I suggest that you split up the macros from the 'work' e.g. the group: "1. Welcome" into another lib:token?
This way it makes it much easier to update an upgrade for the lib as you just replace the lib:Notebook, without the need to move all the macros to the new lib. I've done tihs in the bot where all the macro are on lib:ontokenmove while all settings, macros, properties, etc. are on lib:eventmacros.
Updating then results in just replacing lib:ontokenmove without anything (like your settings) being lost.

And here:
Manual markdown version.txt
(71.11 KiB) Downloaded 17 times
is an update of the markdown version of the BoT manual. I've made your suggested changes. You can again use it to see where stuff goes wrong.

edit: I've looked at your code and to fix issue 6 (apostrophe, aka capostrophe) replace this line:

Code: Select all

[h:entry=decode(getStrProp(macro.args,"command"))]
with this one:

Code: Select all

[h:entry=decode(replace(getStrProp(macro.args,"command"),"%27","`")	)]
that way you *can* use the apostrophe as its replace with the tick as soon as its parsed.

btw. is there a particular reason you use flat make up of your code (no indentations)? It makes your code really hard to read.
how I code

Code: Select all

[h:SharedImageSize		= ""]
[h:Roll				= "[email protected]:Character"]
[h:DiceOutput			= "all"]
[h:Output			= "gm-self"]

<!-------------------    RENDER     ---------------------->
[h:dir				= getStrProp(macro.args,"dir")]
[h:libName			= getStrProp(macro.args,"libName")]
[h:libLocation			= getStrProp(macro.args,"libLocation")]
[h:share			= getStrProp(macro.args,"share")]
[h:playerexec			= listFind(getStrProp(macro.args,"playerexec"),getPlayerName())]
[h:handout			= getStrProp(macro.args,"handout")]

[h:title			= libName]
[r:exe				= ""]

[h:entry			= decode(replace(getStrProp(macro.args,"command"),"%27","`")	)]

<!-------------- REPLACEMENT---------------->
[h:entry			= replace(entry,"\\?","QESTIONMARKPLACEHOLDER")]
[h:entry			= replace(entry,"->","ARROWPLACEHOLDER")]
[h:entry			= replace(entry,"=>","ARROW2PLACEHOLDER")]

[h:entry			= replace(entry,"\\\\\\*","ASTERISKPLACEHOLDER")]
[h:entry			= replace(entry,"\\\\\\`","BACKTICKPLACEHOLDER")]
[h:entry			= replace(entry,"\\\\\\_","UNDERSCOREPLACEHOLDER")]
[h:entry			= replace(entry,"\\\\\\#","POUNDSIGNPLACEHOLDER")]

<!-------------- HEADER 6---------------->
[h:id				= strfind(entry,"#{6}\\s(.*)")]
[h,count(getFindCount(id)),CODE:{
	[find			= getGroup(id,roll.count+1,0)]
	[group			= getGroup(id,roll.count+1,1)]
	[entry			= replace(entry,find,"<h6>"+group+"</h6>",1)]
}]

User avatar
aliasmask
Deity
Posts: 8579
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Rod's 'Drop-In' Markdown Notebook

Post by aliasmask »

With my chat lib token I have my own formatting and I recommend having something in markup like the code block to ignore all markup formatting and maybe a different block just to do html only.

User avatar
rtakehara
Cave Troll
Posts: 37
Joined: Mon Nov 11, 2019 5:11 pm
Contact:

Re: Rod's 'Drop-In' Markdown Notebook

Post by rtakehara »

3, 5 and 6. There are a lot of workarounds in the earlier codes that I learned how to deal with them later using regex lookahead, if I rework some of the code, it will probably solve many issues, I will try to it.

7. oh, that's my fault, I am kinda proud of my English skills, but it's not my native language, so I constantly mix similar words. Underline is not supported by default in vanilla Markdown, so its not supported because my primary goal was to support all markdown syntax, adding extended syntax was a secondary goal, but implementing it should be super easy.
New: apparently its not possible to escape the pipe character: "|".
Yeah, there is very few escaped characters (for now, only _#` and *), after I do some reworking I will make sure to implement at least all vanilla markdown ones
might I suggest that you split up the macros from the 'work' e.g. the group: "1. Welcome" into another lib:token?
Probably, the only problem will be for the engine work with multiple notebooks, but It probably could be done by placing the Open Notebook and Options macros on the data token, not on the engine.

Pros, other then what you mentioned, is that I could do more macros, I did as few as I could, render is basically 3 complex macros in 1, and setup is a lot of small macros in 1, I did that to let more space for the data macros, visually speaking, but as a side effect, one single argument may break everything...

Cons would be hella lot of rework
that way you *can* use the apostrophe as its replace with the tick as soon as its parsed.
I don't have it implemented yet, and I don't know if its possible, but I would want to implement support for inline code, it's done by adding `backticks` at the beginning and end, wouldn't that make it impossible to differentiate quotes from codes? Though as an alternative, I could just use ``double backtics`` instead of `single`, for inline code, ```triple``` for multi line and leave `single` to apostrophes. I'll see.
btw. is there a particular reason you use flat make up of your code (no indentations)? It makes your code really hard to read.
I don't use indentations because I don't know how to get rid of them. I can add them by selecting a bunch of text and pressing tab, but how do I remove them all at once? I know, I know, its horrible... I am not a programmer...
With my chat lib token I have my own formatting and I recommend having something in markup like the code block to ignore all markup formatting and maybe a different block just to do html only.
I will do that. And there is probably a good way to just make html work flawlessly I am starting to understand regex a little better and it would probably be really useful to make it happen, thanks for the tip

User avatar
wolph42
Deity
Posts: 9708
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Rod's 'Drop-In' Markdown Notebook

Post by wolph42 »

Probably, the only problem will be for the engine work with multiple notebooks, but It probably could be done by placing the Open Notebook and Options macros on the data token, not on the engine.

Pros, other then what you mentioned, is that I could do more macros, I did as few as I could, render is basically 3 complex macros in 1, and setup is a lot of small macros in 1, I did that to let more space for the data macros, visually speaking, but as a side effect, one single argument may break everything...

Cons would be hella lot of rework
biggest pro is shareability of others work. When someone does e.g. pathfinder rulebook (S)he can simply share the lib. Multiple lib can contain multiple books.
wouldn't that make it impossible to differentiate quotes from codes?
yes it would, good point, requires some thinking on my side...
I don't use indentations because I don't know how to get rid of them. I can add them by selecting a bunch of text and pressing tab, but how do I remove them all at once?
shift tab

User avatar
rtakehara
Cave Troll
Posts: 37
Joined: Mon Nov 11, 2019 5:11 pm
Contact:

Re: Rod's 'Drop-In' Markdown Notebook

Post by rtakehara »

I updated the token, rewrote a lot of codes, here's some of the changes:
1. I can't seem to implement images from tables (or any other source), currently using this:
<img src='"+tableImage('tbl_Image',26)+"' alt='Nildiks Room Description'>
the old engine just took the raw data from getMacroCommand(), so functions worked like plain strings, now I added an eval() when it detects functions, to do so, like the exemple above, use:

Code: Select all

<img src='"+[r:tableImage('tbl_Image',26)]+"' alt='Nildiks Room Description'>
The markdown notation should work too:

Code: Select all

![]([r:tableImage('tbl_Image',26)] "Nildiks Room Description")
2. I can't seem to use sublists, so e.g. 3 items where the 2nd item has 4 sublist items.
Is that my lack of RTFM or are those not present?
It now works with 1 nested level, more levels work as if they were level 1. It doesn't work with more levels because I suck at programming

3. no, just adding a new line below the table does NOT work.

I mean this:
test.png
test.png (40.72 KiB) Viewed 830 times
I can't find a way to detect the end of the string, not sure if its a problem with maptools or I am using regex wrong, but two empty lines, or one line and text are working fine for me, let me know if I got it wrong...

Edit: Managed to do it, Thanks for the tip on how \$ works!

5 and 6. I redid a lot how code blocks work, triple ticks (```) work on separate lines and make a green square as the info boxes in D&D books, triple ticks with the text code (```code) will make a code block that ignores formatting, and one tick (`) works for in line code like `this`, it also ignores formatting, and since now it understands MapTool functions, things like [r: listCount(...)] should be `[r: listCount(...)]` or it will try to run the code. I hope it works fine, let me know.
7. I'm also missing underline, is that correct?
Not anymore! Vanilla Markdown uses _underscore_ and *asterisks* to do the same thing, now, I use just *asterisks* for bold and italic, and _underscore_ for underline.

Also all escaped characters from Markdown work, including pipes (|)


Also:

With my chat lib token I have my own formatting and I recommend having something in markup like the code block to ignore all markup formatting and maybe a different block just to do html only.
I did it both! A code for ignoring formatting, and one for HTML, the only problem is that maptools seem to transform any number of line breaks, spaces and tabs into one single space, so I added them back, hope that's acceptable

and finally
shift tab
That's extremely helpful, I find not being able to do that sightly more unbearable than flat code

User avatar
aliasmask
Deity
Posts: 8579
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Rod's 'Drop-In' Markdown Notebook

Post by aliasmask »

You can use <pre>...</pre> to preserve spaces and line spacing for the output.

User avatar
wolph42
Deity
Posts: 9708
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Rod's 'Drop-In' Markdown Notebook

Post by wolph42 »

Nice job! Can't wait (to find time) to get to work with this.

@AM: nice tip, I've used that quite a bit and always forget about it...

User avatar
rtakehara
Cave Troll
Posts: 37
Joined: Mon Nov 11, 2019 5:11 pm
Contact:

Re: Rod's 'Drop-In' Markdown Notebook

Post by rtakehara »

Yeah, that was very helpful! And easy to fix, updated already.

User avatar
wolph42
Deity
Posts: 9708
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Rod's 'Drop-In' Markdown Notebook

Post by wolph42 »

this starts to look pretty awesome, note that I noticed that 'bot' is still in your lib :D not that I'd worry about it, but I guess you should remove it?

anyway, I've used your suggestion:
![]([r:tableImage('tbl_Image',26)] "Nildiks Room Description")
which works... excep that:
Screenshot 2019-12-04 23.14.35.png
Screenshot 2019-12-04 23.14.35.png (93.43 KiB) Viewed 795 times
so how do I size these down to something acceptable?

edit: 2 issues I've encountered after checking it out:
1. with code blocks it would be nice if single new lines are NOT ignored (double new lines work, but leave a lot of space which is not useful in a codeblock)
2. the table 'markup code' ends up in the maptool chatbox. I think you forgot a 'h:' somewhere.
edit: yup, line 152 or 152:

Code: Select all

<!-------------- TABLE---------------->
[h:id=strfind(entry,"(\\|{1}[\\s\\S]*?\\|{1})(?=\\n{2})|(\\|{1}[\\s\\S]*?\\|{1})(?=\$)")]
[r,count(getFindCount(id),"<br><br>"),code:{
	[h:find=getGroup(id,roll.count+1,1)]
	[h:find2=getGroup(id,roll.count+1,2)]
	[r:find=if(find=="",find2,find)]
note that you ONLY need an outside h: and all inside code output will be hidden. So this:

Code: Select all

[h:id=strfind(entry,"#{1}\\s(.*)")]
[h,count(getFindCount(id)),code:{
	[h:find=getGroup(id,roll.count+1,0)]
	[h:group=getGroup(id,roll.count+1,1)]
	[h:entry=replace(entry,find,"<h1>"+group+"</h1>",1)]
}]
and this

Code: Select all

[h:id=strfind(entry,"#{1}\\s(.*)")]
[h,count(getFindCount(id)),code:{
	[find=getGroup(id,roll.count+1,0)]
	[group=getGroup(id,roll.count+1,1)]
	[entry=replace(entry,find,"<h1>"+group+"</h1>",1)]
}]
do EXACTLY the same thing! Although for debug purposes they can be useful...

Post Reply

Return to “User Creations”