Skip to content

Commit

Permalink
Communication: Add support for mentioning FAQs (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
anian03 authored Oct 26, 2024
1 parent fd3a866 commit 13e3416
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Sources/ArtemisMarkdown/RegexReplacementVisitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ enum RegexReplacementVisitors {
return "![Message](local://fa-message) [#\(match.id)](mention://message/\(match.id))"
}

// (?<FAQ>\[faq].*?\[\/faq]
static let faqs = RegexReplacementVisitor(
regex: #/\[faq\](?<name>.*?)\((?<path>/courses/\d+/faq\?faqId=\d+)\)\[/faq\]/#
) { match in
guard let baseURL = UserSessionFactory.shared.institution?.baseURL,
let url = URL(string: String(match.path), relativeTo: baseURL) else {
return String(match.0)
}
return "![FAQ](local://fa-question) [\(match.name)](mention://faq/\(url.query() ?? ""))"
}

// (?<SLIDE>\[slide].*?\[\/slide])
static let slides = RegexReplacementVisitor(
Expand All @@ -100,7 +110,8 @@ enum RegexReplacementVisitors {
lectures.visit(input:),
members.visit(input:),
messages.visit(input:),
slides.visit(input:)
slides.visit(input:),
faqs.visit(input:)
] {
visit(&input)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "question.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 13e3416

Please sign in to comment.