Skip to content

Commit

Permalink
Match main title as if missing
Browse files Browse the repository at this point in the history
  • Loading branch information
WilStead committed Mar 1, 2023
1 parent c9cefc1 commit d9e4a5d
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: publish
env:
VERSION: '0.19.2-preview'
VERSION: '0.19.3-preview'
PRERELEASE: true
on:
push:
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.19.3-preview
### Fixed
- Match main title as if missing

## 0.19.2-preview
### Fixed
- `PageTitle` parsing bug
Expand Down
8 changes: 8 additions & 0 deletions src/MarkdownExtensions/Transclusions/TransclusionParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ public static async ValueTask<string> TranscludeAsync(
if (!string.IsNullOrWhiteSpace(code))
{
var codeTitle = PageTitle.Parse(code);
if (codeTitle.Title?.Equals(options.MainPageTitle) == true)
{
codeTitle = codeTitle.WithTitle(null);
}
if (string.IsNullOrEmpty(codeTitle.Namespace))
{
codeTitle = codeTitle.WithNamespace(options.ScriptNamespace);
Expand Down Expand Up @@ -343,6 +347,10 @@ public static async ValueTask<string> TranscludeAsync(
{
pageTitle = pageTitle.WithNamespace("-");
}
if (pageTitle.Title?.Equals(options.MainPageTitle) == true)
{
pageTitle = pageTitle.WithTitle(null);
}
transcludedPages.Add(pageTitle);

var page = await IPage<Page>.GetExistingPageAsync<Page>(
Expand Down
30 changes: 15 additions & 15 deletions src/Models/PageTitle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ public PageTitle(string? title, string? @namespace = null, string? domain = null
/// </para>
/// <para>
/// If the domain or namespace are <see langword="null"/> the entire segment, up to and
/// including the semicolon, may be omitted. They may also be included as an empty segment, with
/// the delimiting semicolon (and parenthesis for domain) but no content, or only whitespace.
/// including the colon, may be omitted. They may also be included as an empty segment, with
/// the delimiting colon (and parenthesis for domain) but no content, or only whitespace.
/// </para>
/// <para>
/// If the title is <see langword="null"/> but not the domain or namespace, the string must
/// terminate in a semicolon, to remove any ambiguity with cases where the last part could also
/// terminate in a colon, to remove any ambiguity with cases where the last part could also
/// be construed as a title.
/// </para>
/// <para>
Expand All @@ -128,7 +128,7 @@ public PageTitle(string? title, string? @namespace = null, string? domain = null
/// considered part of the text, and not a domain indicator.
/// </para>
/// <para>
/// Excess semicolons are interpreted as part of the title.
/// Excess colons are interpreted as part of the title.
/// </para>
/// </remarks>
public static PageTitle Parse(string? s, IFormatProvider? provider = null)
Expand Down Expand Up @@ -160,12 +160,12 @@ public static PageTitle Parse(string? s, IFormatProvider? provider = null)
/// </para>
/// <para>
/// If the domain or namespace are <see langword="null"/> the entire segment, up to and
/// including the semicolon, may be omitted. They may also be included as an empty segment, with
/// the delimiting semicolon (and parenthesis for domain) but no content, or only whitespace.
/// including the colon, may be omitted. They may also be included as an empty segment, with
/// the delimiting colon (and parenthesis for domain) but no content, or only whitespace.
/// </para>
/// <para>
/// If the title is <see langword="null"/> but not the domain or namespace, the string must
/// terminate in a semicolon, to remove any ambiguity with cases where the last part could also
/// terminate in a colon, to remove any ambiguity with cases where the last part could also
/// be construed as a title.
/// </para>
/// <para>
Expand All @@ -174,7 +174,7 @@ public static PageTitle Parse(string? s, IFormatProvider? provider = null)
/// considered part of the text, and not a domain indicator.
/// </para>
/// <para>
/// Excess semicolons are interpreted as part of the title.
/// Excess colons are interpreted as part of the title.
/// </para>
/// <para>
/// Note: this method always returns <see langword="true"/>; there is no string which cannot be
Expand Down Expand Up @@ -256,12 +256,12 @@ public static bool TryParse(
/// </para>
/// <para>
/// If the domain or namespace are <see langword="null"/> the entire segment, up to and
/// including the semicolon, may be omitted. They may also be included as an empty segment, with
/// the delimiting semicolon (and parenthesis for domain) but no content, or only whitespace.
/// including the colon, may be omitted. They may also be included as an empty segment, with
/// the delimiting colon (and parenthesis for domain) but no content, or only whitespace.
/// </para>
/// <para>
/// If the title is <see langword="null"/> but not the domain or namespace, the string must
/// terminate in a semicolon, to remove any ambiguity with cases where the last part could also
/// terminate in a colon, to remove any ambiguity with cases where the last part could also
/// be construed as a title.
/// </para>
/// <para>
Expand All @@ -270,7 +270,7 @@ public static bool TryParse(
/// considered part of the text, and not a domain indicator.
/// </para>
/// <para>
/// Excess semicolons are interpreted as part of the title.
/// Excess colons are interpreted as part of the title.
/// </para>
/// <para>
/// Note: this method always returns <see langword="true"/>; there is no string which cannot be
Expand Down Expand Up @@ -332,18 +332,18 @@ public bool Equals(PageTitle other) => string.CompareOrdinal(Domain, other.Domai
/// </para>
/// <para>
/// If the domain is <see langword="null"/> the entire segment, up to and including the
/// semicolon, will be omitted.
/// colon, will be omitted.
/// </para>
/// <para>
/// If both the domain and namespace are <see langword="null"/> only the title will be shown,
/// with no semicolons.
/// with no colons.
/// </para>
/// <para>
/// If all three parts are <see langword="null"/> an empty string will be returned.
/// </para>
/// <para>
/// If the title is <see langword="null"/> but not the domain or namespace, the string will
/// terminate in a semicolon, to remove any ambiguity with cases where the last part could also
/// terminate in a colon, to remove any ambiguity with cases where the last part could also
/// be construed as a title.
/// </para>
/// </remarks>
Expand Down
5 changes: 5 additions & 0 deletions src/WikiExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,11 @@ public static async Task<PagedListDTO<LinkInfo>> GetWhatLinksHereAsync(
WikiOptions options,
WhatLinksHereRequest request)
{
var title = request.Title;
if (title.Title?.Equals(options.MainPageTitle) == true)
{
title = title.WithTitle(null);
}
var page = await IPage<Page>
.GetExistingPageAsync<Page>(dataStore, request.Title)
.ConfigureAwait(false);
Expand Down

0 comments on commit d9e4a5d

Please sign in to comment.