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 =
Image: 
%r{\A!\[(?<alt>[^|\]]*)(?:\|(?<dimensions>[^\]]*))?\]\(upload://(?<url>[^)]+)\)}- ATTACHMENT_PATTERN =
Attachment: [filename|attachment](upload://sha1.ext) (size)
%r{ \A \[(?<filename>[^|\]]*)\|attachment\] \(upload://(?<url>[^)]+)\) (?:\s*\((?<size>[^)]+)\))? }xi
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.
43 44 45 46 47 48 49 50 51 |
# File 'lib/markbridge/processors/discourse_markdown/detectors/upload.rb', line 43 def detect(input, pos) remaining = input[pos..] case input[pos] when "!" detect_image(remaining, pos) when "[" (remaining, pos) end end |