-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic Markdown Rendering and Bibliography
- Added basic support for markdown rendering. - Update to the new BookReference.
- Loading branch information
1 parent
74fe5db
commit 6cdb23e
Showing
97 changed files
with
3,536 additions
and
360 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
// To update the version of Uno please update the version of the Uno.Sdk here. See https://aka.platform.uno/upgrade-uno-packages for more information. | ||
"msbuild-sdks": { | ||
"Uno.Sdk": "5.4.0-dev.188" | ||
"Uno.Sdk": "5.6.0-dev.144" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,89 @@ | ||
using Symptum.Core.Helpers; | ||
using Symptum.Core.Subjects.Books; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Web; | ||
|
||
namespace Symptum.Core.Data.Bibliography; | ||
|
||
internal class BookReference : LiteratureReference | ||
public record BookReference : LiteratureReference | ||
{ | ||
public string Section { get; set; } | ||
private static readonly string _bookId = "n"; | ||
private static readonly string _bookEdition = "ed"; | ||
private static readonly string _bookVolume = "vol"; | ||
|
||
#region Properties | ||
|
||
public string? Section { get; init; } | ||
|
||
public int Edition { get; init; } | ||
|
||
public int ISBN { get; init; } | ||
|
||
#endregion | ||
|
||
// @book?n={id}&ed={edition}&vol={volume}#{pages} | ||
public static bool TryParse(string? text, [NotNullWhen(true)] out BookReference? bookReference) | ||
{ | ||
bool parsed = false; | ||
bookReference = null; | ||
if (!string.IsNullOrEmpty(text)) | ||
{ | ||
var values = text.Split(ParserHelper.BookReferenceDelimiter); | ||
if (values.Length == 2) | ||
{ | ||
string bookString = values[0][0] == '@' && values[0].Length > 6 ? values[0].Remove(0, 6) : values[0]; | ||
(Book? book, int edition, int volume) = ParseBookString(bookString); | ||
|
||
bookReference = new() | ||
{ | ||
Id = book?.Id, | ||
Title = book?.Title, | ||
Authors = book?.Authors, | ||
Edition = edition, | ||
Volume = volume, | ||
Pages = values[1] | ||
}; | ||
parsed = true; | ||
} | ||
} | ||
|
||
return parsed; | ||
} | ||
|
||
private static (Book? book, int edition, int volume) ParseBookString(string bookString) | ||
{ | ||
Book? book = null; | ||
int edition = 0; | ||
int volume = 0; | ||
var col = HttpUtility.ParseQueryString(bookString); | ||
if (col != null && col.Count > 0) | ||
{ | ||
string? bookCode = col[_bookId]; | ||
string? bookEdition = col[_bookEdition]; | ||
string? bookVolume = col[_bookVolume]; | ||
if (!string.IsNullOrEmpty(bookCode)) | ||
book = BookStore.Books.FirstOrDefault(x => x.Id == bookCode); | ||
if (int.TryParse(bookEdition, out int edNo)) | ||
edition = edNo; | ||
if (int.TryParse(bookVolume, out int volNo)) | ||
volume = volNo; | ||
} | ||
|
||
return (book, edition, volume); | ||
} | ||
|
||
public int Edition { get; set; } | ||
public override string ToString() | ||
{ | ||
var col = HttpUtility.ParseQueryString(string.Empty); | ||
col.Add(_bookId, Id ?? string.Empty); | ||
col.Add(_bookEdition, Edition.ToString()); | ||
col.Add(_bookVolume, Volume.ToString()); | ||
return "@book?" + col.ToString() + ParserHelper.BookReferenceDelimiter + Pages; | ||
} | ||
|
||
public int ISBN { get; set; } | ||
public override string GetPreviewText() | ||
{ | ||
return $"{Title} by {Authors}, " + | ||
$"Edition: {Edition}, Volume: {Volume}, Pages: {Pages}"; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
6 changes: 3 additions & 3 deletions
6
src/Symptum.Core/Data/Bibliography/JournalArticleReference.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
namespace Symptum.Core.Data.Bibliography; | ||
|
||
internal class JournalArticleReference : LiteratureReference | ||
public record JournalArticleReference : LiteratureReference | ||
{ | ||
public string JournalName { get; set; } | ||
public string? JournalName { get; init; } | ||
|
||
public int Issue { get; set; } | ||
public int Issue { get; init; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
namespace Symptum.Core.Data.Bibliography; | ||
|
||
internal class LinkReference : ReferenceBase | ||
public record LinkReference : ReferenceBase | ||
{ | ||
|
||
} |
20 changes: 10 additions & 10 deletions
20
src/Symptum.Core/Data/Bibliography/LiteratureReference.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
namespace Symptum.Core.Data.Bibliography; | ||
|
||
public class LiteratureReference : ReferenceBase | ||
public record LiteratureReference : ReferenceBase | ||
{ | ||
public string Authors { get; set; } | ||
public string? Authors { get; init; } | ||
|
||
public string Title { get; set; } | ||
public string? Title { get; init; } | ||
|
||
public string Description { get; set; } | ||
public string? Description { get; init; } | ||
|
||
public int Volume { get; set; } | ||
public int Volume { get; init; } | ||
|
||
public string Pages { get; set; } | ||
public string? Pages { get; init; } | ||
|
||
public int Year { get; set; } | ||
public int Year { get; init; } | ||
|
||
public string Editors { get; set; } | ||
public string? Editors { get; init; } | ||
|
||
public string Publisher { get; set; } | ||
public string? Publisher { get; init; } | ||
|
||
public Uri Url { get; set; } | ||
public Uri? Url { get; init; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,34 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace Symptum.Core.Data.Bibliography; | ||
|
||
public class ReferenceBase : ObservableObject | ||
public abstract record ReferenceBase | ||
{ | ||
#region Properties | ||
|
||
public string? Id { get; init; } | ||
|
||
#endregion | ||
|
||
public static bool TryParse(string? text, [NotNullWhen(true)] out ReferenceBase? reference) | ||
{ | ||
bool parsed = false; | ||
reference = null; | ||
|
||
if (!string.IsNullOrEmpty(text)) | ||
{ | ||
if (text.StartsWith("@book?")) | ||
{ | ||
if (BookReference.TryParse(text, out BookReference? bookReference)) | ||
{ | ||
parsed = true; | ||
reference = bookReference; | ||
} | ||
} | ||
} | ||
|
||
return parsed; | ||
} | ||
|
||
public virtual string GetPreviewText() => string.Empty; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.