36 votes
Accepted

Regex to parse horizontal rules in Markdown

Congratulations, what you have here is a case of really really bad backtracking. Remember the StackOverflow outage in July 2016? Because it's explained quite nicely there. regex101 is so kind as to ...
Vogel612's user avatar
  • 25.2k
10 votes
Accepted

Markdown Display in WPF

...
Peter Taylor's user avatar
  • 24.1k
7 votes

Regex to parse horizontal rules in Markdown

I have just signed up, so I can only post answers and not comment on the otherwise nice answer of Vogel612. I would like to add that it is also possible in PCRE to make ...
TimVdE's user avatar
  • 95
7 votes
Accepted

Markdown Markup Editor: MK2

OnPropertyChanged() This method to raise the PropertyChanged event needs only to be called if the value is changed which isn't ...
Heslacher's user avatar
  • 50.4k
6 votes
Accepted

Markdown Markup Markleft Markright Editor

You want to unleash the almighty power of WPF, and bind to a ViewModel; WPF and the Model-View-ViewModel design go completely hand-in-hand, especially if you like your code testable. As it stands the ...
Mathieu Guindon's user avatar
6 votes

Print code-fenced sections of a Markdown document

While your code looks ok, it could be improved greatly by making use of RS (record separator) and NR number of record, provided ...
oliv's user avatar
  • 231
4 votes
Accepted

Command line todo list manager

Your program expects the user to refer to completed or incomplete tasks by a numeric index. However, the Markdown file contains an unnumbered bulleted list, which forces the user to count the items ...
200_success's user avatar
4 votes

Print code-fenced sections of a Markdown document

The Code looks perfect to me. I thought about using the flip-flop operator, but since you take additional action at the beginning and the end of the code block, this may be difficult in this case. <...
Roland Illig's user avatar
  • 21.3k
4 votes

Markdown Markup Editor: MK2

Some feedback on the XAML: Good that you set d:DataContext as it saves some pain when bindings are ~compiletime checked (if the designer has the view open) ...
Johan Larsson's user avatar
3 votes

Regex to parse horizontal rules in Markdown

Now I may be wrong, but I am able to match: ------- from 3 and up - - - - - from 3 and up While not matching the 'abc' example (or any line that throws a non-horizontal rule symbol into the mix ...
Matthew C. Lewis's user avatar
3 votes
Accepted

Formatter for converting links in a legacy markup to markdown

The magic numbers used to check the diff, e.g., diff[0][0] == 1 && diff[1][0] == 0 One small improvement is that ...
CertainPerformance's user avatar
3 votes
Accepted

Adding prefixes to headers in markdown

I may not be considering all fringe cases (please enlighten me if this breaks with any realistic input), but all of the logic can be packed into a single ...
mickmackusa's user avatar
  • 8,574
3 votes

Makefile for building classwork from markdown files and LaTeX

I have a similar script. So from my experiences I would: build the pdfs through latexmk sometimes it needs more runs of pdflatex. I found it too hard to get right in plain make. have directories ...
bdecaf's user avatar
  • 402
3 votes

Bash script to extract HTML comment into a Markdown file

A bug If your html contains a backspace character e.g <p>The special character \n is a way to include read line</p> your code interprets it a The ...
Tolani's user avatar
  • 2,465
2 votes

Markdown parser, template engine, and then some

One-lining log Your log method can become this: print(a) if DEBUG_MODE else None This ...
ArtOfCode's user avatar
  • 562
2 votes

Monthly attendance report for some company employees

I think you can simplify your code quite a bit if you compute all the summary metrics once for all in a single function. This way, you also avoid repetitive calls to read_excel: ...
flodel's user avatar
  • 3,525
2 votes
Accepted

Converting Markdown to HTML using Go

Performance Regex regex.MustCompile() is very expensive! Do not use this method inside a loop ! instead, define your regex as global variables only once: <...
felix's user avatar
  • 588
2 votes
Accepted

Fetch StackOverflow questions and save them to a markdown table

Things look good and well organised at first glance. However, there are a few things you can make use of. Use f-string over using str.format. The former is more performant. You can group the columns ...
hjpotter92's user avatar
  • 8,716
2 votes
Accepted

Tab 2 spaces convertor (for markdown)

A lot of the code in your while loop can be replaced with a for loop using enumerate() and a toggled boolean. You should be able to replace your code from ...
Confettimaker's user avatar
2 votes
Accepted

Script to loop through a list of YouTube channels, and output metadata to a Markdown file

Nice script! Read multiple values by name rather than into an array Instead of: ...
janos's user avatar
  • 111k
1 vote
Accepted

Markdown code formatter

Bug Take a look at what happens if I combine block doc comments and doc test. This perfectly reasonable code: ...
Aiden4's user avatar
  • 266
1 vote

Fetch StackOverflow questions and save them to a markdown table

The code looks really good, so I'll ask some questions on the design decisions that have been made. Path(__file__).parent.resolve() I haven't used this before, so ...
spyr03's user avatar
  • 3,032
1 vote
Accepted

Easy to use code preparation script for CodeReview questions

An alternative to defaulting variables by self-assigning with fallback is to use ${parameter:=word} at the point of first use: ...
Toby Speight's user avatar
  • 74.4k
1 vote
Accepted

Print code-fenced sections of a Markdown document

You could shorten the code with the next statement , which skips the current line. See in GNU.org AWK manual Next-Statement. Also you can use your variable as a ...
CiaPan's user avatar
  • 1,541
1 vote

Regex to parse horizontal rules in Markdown

The following is closer to the CommonMark Spec as "it is required that all of the characters other than spaces or tabs be the same" and only up to 3 spaces are permitted in front of the ...
ChrisW's user avatar
  • 111
1 vote

Source formatting of Markdown Table

To complete on @Graipher's answer, I would simplify the formating of the rows using list-comprehensions/generator expressions rather than building a list to feed into ...
301_Moved_Permanently's user avatar
1 vote
Accepted

Source formatting of Markdown Table

As far as I can see, there is no need for the StringIO (?). You can just use query.split('\n'). Regardless, that for loop can be ...
Graipher's user avatar
  • 40.9k
1 vote

Bash script to extract HTML comment into a Markdown file

A Bash loop is not the best approach. If you are doing a lot of line-by-line processing, and invoking grep a lot, then awk ...
200_success's user avatar
1 vote
Accepted

Truncating article text

About the naming, and grouping your code. First improvement, change name of the variable from truncate to should_truncate, ...
Nermin's user avatar
  • 201

Only top scored, non community-wiki answers of a minimum length are eligible