Class: Markbridge::Processors::DiscourseMarkdown::Detectors::Upload
- Defined in:
- lib/markbridge/processors/discourse_markdown/detectors/upload.rb
Overview
Detects Discourse upload references using upload:// URLs.
Supports two formats:
-
Images: 
-
Attachments: [filename|attachment](upload://sha1.ext) (size)
Constant Summary collapse
- IMAGE_PATTERN =
Pattern for image: 
%r{!\[([^\]]*)\]\(upload://([^)]+)\)}- ATTACHMENT_PATTERN =
Pattern for attachment: [filename|attachment](upload://sha1.ext) followed by optional (size)
%r{\[([^\]]*\|attachment)\]\(upload://([^)]+)\)(\s*\([^)]+\))?}
Instance Method Summary collapse
-
#detect(input, pos) ⇒ Match?
Attempt to detect an upload at the given position.
Instance Method Details
#detect(input, pos) ⇒ Match?
Attempt to detect an upload at the given position.
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/markbridge/processors/discourse_markdown/detectors/upload.rb', line 36 def detect(input, pos) char = input[pos] return nil unless char == "!" || char == "[" remaining = input[pos..] if char == "!" detect_image(remaining, pos) else (remaining, pos) end end |