-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce some save markdown rendering
- Loading branch information
1 parent
fe7242f
commit 6ad4636
Showing
9 changed files
with
36 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module Hackweek | ||
class MarkdownRenderer < Redcarpet::Render::HTML | ||
include Rails.application.routes.url_helpers(only_path: true) | ||
|
||
def preprocess(fulldoc) | ||
# @user links | ||
#fulldoc.gsub!(/([^\w]|^)@([-\w]+)([^\w]|$)/) \ | ||
# {"#{Regexp.last_match(1)}[@#{Regexp.last_match(2)}](#{user_path(Regexp.last_match(2))})#{Regexp.last_match(3)}" } | ||
# sanitize the HTML we get | ||
Sanitize.fragment(fulldoc, Sanitize::Config.merge(Sanitize::Config::RESTRICTED, | ||
elements: Sanitize::Config::RESTRICTED[:elements] + ['pre'], | ||
remove_contents: true | ||
)) | ||
end | ||
end | ||
end |