Hide UID in title when previewed with Marked 2
Hi,
I write my note title as follow : # date-based-uid note title. But I also have notes titled without UID.
I use Marked 2 app to preview/export my notes. My goal is to make Marked 2 hide the UID in the title when previewed.
I think it is possible to reach the goal as follow:
- Write a preprocessor script for Marked 2, which add a
spanhtml tag around UID only when there is an UID inh1tag (the title) - Hide
h1 spanin the CSS theme, so that we only see the note title without the UID
Can someone help me write a simple Marked 2 preprocessor script for that?
Howdy, Stranger!

Comments
I found a solution for the following expected behavior in Marked 2 app:
When (and only when) I preview a note containing UID in title (like
# 202004061230 Title note), the UID is removed in Marked 2.#!/usr/bin/env ruby begin input = STDIN.read.force_encoding('utf-8') rescue input = STDIN.read end class String def remove_first_line! first_newline = (index("\n") || size - 1) + 1 slice!(0, first_newline).sub("\n",'') end end title = input.remove_first_line! title.gsub!(/[0-9]{12}/) do |m| match = Regexp.last_match uid = match[1] "<span>#{uid}</span>" end input = title + "\n" + input print inputAdd the file as Marked 2 preprocessor (like this
Add in the theme (css file)
#wrapper h1 span {display: none;}I don't know at all Ruby, I wrote this code quickly after some Internet search, so it can surely be simplified and optimized.
Update with a much simpler solution:
#!/usr/bin/env ruby begin input = STDIN.read.force_encoding('utf-8') rescue input = STDIN.read end input = input.gsub(/^#\s[0-9]{12}/, "#") print inputThat's all.