Output HTML through the Markdown parser and search for DOM elements using Nokogiri.If Markdown and/or search criteria are complicated, this is the surest thing.
An advanced Markdown parser such as Redcarpet may have a way to customize the behavior, so you can use it to hook the rendering of the list element and output the data somewhere.
If it's a simple way, you might want to search for the Markdown source by regular expression.
source.scan(/^\s*-\s*\[(.*)\]\s*(.*)$/){|s|...}
US>%s is passed in an array of characters and subsequent strings.There are difficulties such as being indistinguishable from inside and outside the code block or being difficult to handle nested lists, but this is sufficient if you are certain that the source format will be limited.
How about regular expressions (Ruby can only be used in standard libraries)
Sample
http://rubular.com/r/nkgIQByUuS
Easy-to-understand regular expression commentary
http://qiita.com/jnchito/items/893c887fbf19e17d3ff9
Function to search for regular expressions in Ruby
http://ref.xaio.jp/ruby/classes/string/scan
If you make good use of groups, you can get only the checked strings.
Try it.
© 2025 OneMinuteCode. All rights reserved.