mirror of
https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
synced 2025-10-29 17:25:32 +00:00
- Abstracted the XML-HTML Parser into a neat little state machine
- Added Settings classes for all things XML-HTML conversion
This commit is contained in:
60
HaWeb/Settings/ParsingState/LetterState.cs
Normal file
60
HaWeb/Settings/ParsingState/LetterState.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
namespace HaWeb.Settings.ParsingState;
|
||||
|
||||
using HaDocument.Interfaces;
|
||||
using HaXMLReader.Interfaces;
|
||||
using HaXMLReader.EvArgs;
|
||||
using HaDocument.Models;
|
||||
using System.Text;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
public class LetterState : HaWeb.HTMLParser.IState {
|
||||
// Input
|
||||
internal ILibrary Lib;
|
||||
internal IReaderService ReaderService;
|
||||
internal Meta Meta;
|
||||
|
||||
internal IEnumerable<Marginal>? Marginals;
|
||||
|
||||
// State
|
||||
internal bool active_del;
|
||||
internal bool active_skipwhitespace;
|
||||
internal string currline;
|
||||
internal string currpage;
|
||||
internal string oldpage;
|
||||
internal int commid;
|
||||
|
||||
// Parsing-Combinations
|
||||
internal StringBuilder sb_lettertext; // Hauptext
|
||||
internal StringBuilder sb_linecount; // Linke Spalte (Zeilenzählung)
|
||||
internal StringBuilder sb_marginals; // Rechte Spalte (Kommentare)
|
||||
|
||||
|
||||
public LetterState(ILibrary lib, IReaderService readerService, Meta meta, IEnumerable<Marginal>? marginals) {
|
||||
Lib = lib;
|
||||
ReaderService = readerService;
|
||||
Meta = meta;
|
||||
Marginals = marginals;
|
||||
|
||||
SetupState();
|
||||
}
|
||||
|
||||
|
||||
public void SetupState() {
|
||||
sb_lettertext = new StringBuilder();
|
||||
sb_linecount = new StringBuilder();
|
||||
sb_marginals = new StringBuilder();
|
||||
|
||||
active_skipwhitespace = true;
|
||||
currline = "-1";
|
||||
currpage = "";
|
||||
oldpage = "";
|
||||
commid = 1;
|
||||
|
||||
// Initialize State
|
||||
if (Meta.ZH != null) {
|
||||
currpage = Meta.ZH.Page;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user