Skip to content

Commit

Permalink
Fix README rendering in DocumentationController (#371)
Browse files Browse the repository at this point in the history
**This PR:**
- Fixes issues in the rendering of the `README` (e.g., some code blocks)
when browsing to `localhost:300`
- Removes the [markup](https://github.com/github/markup) gem

**Screenshots**

**Fixed:**
<img
src="https://github.com/user-attachments/assets/ebb55ca9-05e1-40a4-800b-fe2980d71a83"
width="400">

**Issue with code block:**
<img
src="https://github.com/user-attachments/assets/7ac8a9c2-ac0d-4a63-93a2-c6f471160896"
width="400">
  • Loading branch information
louis-antonopoulos authored Nov 1, 2024
1 parent d2aa2fd commit 4af60ef
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ gem "rails"

gem "bootsnap", ">= 1.4.4", require: false
gem "bourbon"
gem "github-markup", require: "github/markup"
gem "jsbundling-rails"
gem "pg", ">= 0.18", "< 2.0"
gem "puma", "~> 6.4"
Expand Down
2 changes: 0 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ GEM
ffi (1.17.0-arm64-darwin)
ffi (1.17.0-x86_64-linux-gnu)
filigree (0.4.1)
github-markup (5.0.1)
globalid (1.2.1)
activesupport (>= 6.1)
http-accept (1.7.0)
Expand Down Expand Up @@ -325,7 +324,6 @@ DEPENDENCIES
capybara (>= 3.26)
dotenv-rails
factory_bot_rails
github-markup
jsbundling-rails
listen (>= 3.0.5)
pg (>= 0.18, < 2.0)
Expand Down
13 changes: 6 additions & 7 deletions spec/example_app/app/controllers/documentation_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ def render_documentation_page(name)
path = full_page_path(name)

if File.exist?(path)
html = parse_document(path)
render layout: "documentation", html: html.html_safe
html = File.read(path)
renderer = Redcarpet::Render::HTML.new
markdown = Redcarpet::Markdown.new(renderer, {fenced_code_blocks: true})
rendered_markdown = markdown.render(html)

render layout: "documentation", html: rendered_markdown.html_safe
else
render_not_found
end
Expand All @@ -24,11 +28,6 @@ def full_page_path(page)
Rails.root + "../../#{page}.md"
end

def parse_document(path)
file = path.to_s
GitHub::Markup.render(file, File.read(file))
end

def render_not_found
raise ActionController::RoutingError, "Not Found"
end
Expand Down

0 comments on commit 4af60ef

Please sign in to comment.