Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/Rules
diff options
context:
space:
mode:
authorConnor Shea <connor.james.shea@gmail.com>2016-10-27 10:07:45 +0300
committerConnor Shea <connor.james.shea@gmail.com>2016-10-27 10:07:45 +0300
commit2fd0e31b1acb8b1f58ce1fc3e0b74ca7233c1193 (patch)
treecd05dc61e7591a3bf3138085b132d964bd65c3f5 /Rules
parent5eca43ebf626fecf478a0dc439e6be3f6c7d6b22 (diff)
Get the titles from the Markdown when preprocessing.
Diffstat (limited to 'Rules')
-rw-r--r--Rules16
1 files changed, 16 insertions, 0 deletions
diff --git a/Rules b/Rules
index 71dbb136..add701a8 100644
--- a/Rules
+++ b/Rules
@@ -1,5 +1,21 @@
#!/usr/bin/env ruby
+preprocess do
+ @items.each do |item|
+ if item.identifier.to_s.end_with?(".md") && !item.binary?
+ begin
+ title = item.raw_content.match(/^[#] .*$/s).to_s
+ title.gsub!('# ', '')
+ item[:title] = title
+ # Encoding errors happen on some files for some reason, so we
+ # rescue them.
+ rescue Encoding::CompatibilityError
+ puts "Encoding error"
+ end
+ end
+ end
+end
+
compile '/**/*.html' do
layout '/default.*'
end