Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions app/Libraries/Markdown/OsuMarkdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class OsuMarkdown
{
use Memoizes;

const VERSION = 14;
const VERSION = 15;

const DEFAULT_COMMONMARK_CONFIG = [
'allow_unsafe_links' => false,
Expand Down Expand Up @@ -96,6 +96,13 @@ class OsuMarkdown
'fix_wiki_url' => true,
'generate_toc' => true,
'record_first_image' => true,
'style_block_allowed_classes' => [
'alert-caution',
'alert-note',
'alert-notice',
'alert-tip',
'alert-warning',
],
],
'osu_markdown' => [
'block_modifiers' => ['news'],
Expand Down Expand Up @@ -125,7 +132,14 @@ class OsuMarkdown
'custom_container_inline' => true,
'fix_wiki_url' => true,
'generate_toc' => true,
'style_block_allowed_classes' => ['infobox'],
'style_block_allowed_classes' => [
'alert-caution',
'alert-note',
'alert-notice',
'alert-tip',
'alert-warning',
'infobox',
],
'title_from_document' => true,
'with_gallery' => true,
],
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Wiki/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Page implements WikiObject
use Memoizes, Traits\Es\WikiPageSearch;

const CACHE_DURATION = 5 * 60 * 60;
const VERSION = 9;
const VERSION = 10;

const TEMPLATES = [
'markdown_page' => 'wiki.show',
Expand Down
68 changes: 68 additions & 0 deletions resources/css/bem/osu-md.less
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,74 @@
}
}

@alert-title: ~"> .@{_top}__paragraph:first-child strong:first-of-type";
@alert-inline-p: ~"> .@{_top}__paragraph:only-child:not(:has(> br))";
@alert-inline-compact: ~":not(:has(> .@{_top}__paragraph > br)):has(> .@{_top}__paragraph:only-child)";

.osu-md-alert() {
padding: 10px 15px;
margin: var(--paragraph-space) 0;
border-left: 4px solid;

> .@{_top}__paragraph {
margin: 0;

+ .@{_top}__paragraph {
margin-top: var(--paragraph-space);
}
}

@{alert-title} {
display: block;
padding-bottom: 8px;
font-weight: bold;

&::before {
.fas();
.fa-fw();
content: var(--alert-icon);
margin-right: 8px;
}
}

@{alert-title} + br {
display: none;
}

@{alert-inline-p} {
display: inline;

strong:first-of-type {
display: inline;
padding-bottom: 0;
}
}

&@{alert-inline-compact} {
padding: 5px 15px;
}
}

@alert-types: {
note: @fa-var-info-circle, --hsl-blue-2;
tip: @fa-var-lightbulb, --hsl-lime-2;
notice: @fa-var-bullhorn, --hsl-pink-2;
warning: @fa-var-exclamation, --hsl-red-2;
caution: @fa-var-exclamation-triangle, --hsl-orange-2;
};

each(@alert-types, {
&__alert-@{key} {
.osu-md-alert();
--alert-icon: extract(@value, 1);
border-left-color: hsla(var(extract(@value, 2)), 75%);

@{alert-title} {
color: hsla(var(extract(@value, 2)), 75%);
}
}
});

&__link {
&--footnote-ref {
font-size: @font-size--small-2;
Expand Down
9 changes: 8 additions & 1 deletion tests/Libraries/Markdown/ProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,14 @@ private function loadOutputTest(string $name, string $path, string $extension)
osuExtensionConfig: [
'attributes_allowed' => ['flag', 'id'],
'custom_container_inline' => true,
'style_block_allowed_classes' => ['class-name'],
'style_block_allowed_classes' => [
'alert-caution',
'alert-note',
'alert-notice',
'alert-tip',
'alert-warning',
'class-name',
],
],
osuMarkdownConfig: [
'enable_footnote' => true,
Expand Down
23 changes: 23 additions & 0 deletions tests/Libraries/Markdown/html_markdown_examples/alert.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<div class="osu-md__alert-note">
<p class="osu-md__paragraph"><strong>Note</strong><br />Note body text.</p>
</div>

<div class="osu-md__alert-tip">
<p class="osu-md__paragraph"><strong>Tip</strong><br />Tip body text.</p>
</div>

<div class="osu-md__alert-notice">
<p class="osu-md__paragraph"><strong>Notice</strong><br />Notice body text.</p>
</div>

<div class="osu-md__alert-warning">
<p class="osu-md__paragraph"><strong>Warning</strong><br />Warning body text.</p>
</div>

<div class="osu-md__alert-caution">
<p class="osu-md__paragraph"><strong>Caution</strong><br />Caution body text.</p>
</div>

<div class="osu-md__alert-note">
<p class="osu-md__paragraph"><strong>Good to know</strong><br />Custom title body text.</p>
</div>
29 changes: 29 additions & 0 deletions tests/Libraries/Markdown/html_markdown_examples/alert.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
::: alert-note
**Note**
Note body text.
:::

::: alert-tip
**Tip**
Tip body text.
:::

::: alert-notice
**Notice**
Notice body text.
:::

::: alert-warning
**Warning**
Warning body text.
:::

::: alert-caution
**Caution**
Caution body text.
:::

::: alert-note
**Good to know**
Custom title body text.
:::
11 changes: 11 additions & 0 deletions tests/Libraries/Markdown/html_markdown_examples/alert_inline.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div class="osu-md__alert-note">
<p class="osu-md__paragraph"><strong>See also</strong> <a class="osu-md__link" href="/link">foo</a> and <a class="osu-md__link" href="/link2">bar</a>.</p>
</div>

<div class="osu-md__alert-note">
<p class="osu-md__paragraph"><strong>Main page</strong> <a class="osu-md__link" href="/wiki/Main">Index</a></p>
</div>

<div class="osu-md__alert-note">
<p class="osu-md__paragraph"><strong>Note:</strong> For other uses, see: <a class="osu-md__link" href="/wiki/other">other</a>.</p>
</div>
11 changes: 11 additions & 0 deletions tests/Libraries/Markdown/html_markdown_examples/alert_inline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
::: alert-note
**See also** [foo](/link) and [bar](/link2).
:::

::: alert-note
**Main page** [Index](/wiki/Main)
:::

::: alert-note
**Note:** For other uses, see: [other](/wiki/other).
:::
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p class="osu-md__paragraph"><strong>Example</strong><br />Should render without alert styling.</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
::: alert-notreal
**Example**
Should render without alert styling.
:::
9 changes: 9 additions & 0 deletions tests/Libraries/Markdown/indexable_markdown_examples/alert.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
::: alert-note
**Note**
Searchable note body.
:::

::: alert-warning
**Watch out**
Searchable warning body.
:::
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Note Searchable note body.

Watch out Searchable warning body.


Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
::: alert-note
**See also** [foo](/link) and [bar](/link2).
:::

::: alert-note
**Main page** [Index](/wiki/Main)
:::

::: alert-note
**Note:** For other uses, see: [other](/wiki/other).
:::
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
See also foo and bar.

Main page Index

Note: For other uses, see: other.