-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow additional markdown options #170
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,9 @@ module GovukTechDocs | |
# @option options [Hash] livereload Options to pass to the `livereload` | ||
# extension. Hash with symbols as keys. | ||
def self.configure(context, options = {}) | ||
config_file = ENV.fetch("CONFIG_FILE", "config/tech-docs.yml") | ||
context.config[:tech_docs] = YAML.load_file(config_file).with_indifferent_access | ||
|
||
context.activate :sprockets | ||
|
||
context.sprockets.append_path File.join(__dir__, "../node_modules/govuk-frontend/") | ||
|
@@ -40,15 +43,19 @@ def self.configure(context, options = {}) | |
context.files.watch :source, path: "#{__dir__}/source" | ||
|
||
context.set :markdown_engine, :redcarpet | ||
context.set :markdown, | ||
renderer: TechDocsHTMLRenderer.new( | ||
with_toc_data: true, | ||
api: true, | ||
context: context, | ||
), | ||
fenced_code_blocks: true, | ||
tables: true, | ||
no_intra_emphasis: true | ||
|
||
default_markdown_options = { | ||
renderer: TechDocsHTMLRenderer.new( | ||
with_toc_data: true, | ||
api: true, | ||
context: context, | ||
), | ||
fenced_code_blocks: true, | ||
tables: true, | ||
no_intra_emphasis: true | ||
} | ||
markdown_options = context.config[:tech_docs][:markdown].transform_keys(&:to_sym) || {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens if there are no markdown options specified in the config file? Does this need to be guarded? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe It'll return falsy and the {} will be used. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't seem to like the chaining when I try it:
Looks like it works OK with safe navigation (
|
||
context.set :markdown, default_markdown_options.merge(markdown_options) | ||
|
||
# Reload the browser automatically whenever files change | ||
context.configure :development do | ||
|
@@ -60,8 +67,6 @@ def self.configure(context, options = {}) | |
activate :minify_javascript, ignore: ["/raw_assets/*"] | ||
end | ||
|
||
config_file = ENV.fetch("CONFIG_FILE", "config/tech-docs.yml") | ||
context.config[:tech_docs] = YAML.load_file(config_file).with_indifferent_access | ||
context.activate :unique_identifier | ||
context.activate :warning_text | ||
context.activate :api_reference | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was accidentally added...