public void ParserShouldReadAllMarkdown() { var loader = new BookLoader("SupportedMarkdown.md"); var book = loader.Load(); Assert.Single(book.Chapters); }
private void OpenBook(BookItem Book) { ThisBook = Book; Shared.CurrentBook = Book; PageProcessor.ReadSecondaryTile(Book); CacheStateStory.Begin(); BookLoading = true; if (Book.IsEx()) { Book.XSetProp("Mode", X.Const <string>(XProto.WProtocols, "ACTION_BOOK_META")); } BookLoader BL = new BookLoader(BookLoadComplete); BL.Load(Book, true); BL.LoadIntro(Book, true); BL.LoadCover(Book, true); SyncAnchors(); SetContext(); }
private async Task PinRecord(PinRecord Record) { BookItem Book = await ItemProcessor.GetBookFromId(Record.Id); if (Book == null) { return; } TaskCompletionSource <bool> TCS = new TaskCompletionSource <bool>(); BookLoader BL = new BookLoader(async(b) => { if (b != null) { string TileId = await PageProcessor.PinToStart(Book); if (!string.IsNullOrEmpty(TileId)) { PM.RegPin(b, TileId, false); } } TCS.SetResult(true); }); BL.Load(Book); await TCS.Task; }
public static async Task <AsyncTryOut <Chapter> > TryGetAutoAnchor(BookItem Book, bool Sync = true) { StringResources stx = StringResources.Load("LoadingMessage"); if (Sync) { MessageBus.SendUI(typeof(PageProcessor), stx.Str("SyncingAnchors"), Book.ZItemId); await new AutoAnchor(Book).SyncSettings(); } MessageBus.SendUI(typeof(PageProcessor), stx.Str("ProgressIndicator_Message"), Book.ZItemId); TaskCompletionSource <TOCSection> TCS = new TaskCompletionSource <TOCSection>(); BookLoader BLoader = new BookLoader(b => { if (b == null) { TCS.TrySetResult(null); } else { MessageBus.SendUI(typeof(PageProcessor), stx.Str("LoadingVolumes"), Book.ZItemId); new VolumeLoader(b2 => { if (b2 == null) { TCS.TrySetResult(null); } else { TCS.TrySetResult(new TOCSection(b2)); } }).Load(b); } }); BLoader.Load(Book, true); TOCSection TOCData = await TCS.Task; if (TOCData == null) { return(new AsyncTryOut <Chapter>(false, null)); } if (TOCData.AnchorAvailable) { return(new AsyncTryOut <Chapter>(true, TOCData.AutoAnchor)); } else { return(new AsyncTryOut <Chapter>(false, TOCData.FirstChapter)); } }
public HtmlRendererTests() { var loader = new BookLoader("SupportedMarkdown.md"); var book = loader.Load(); var renderer = new HtmlRenderer(new RenderOptions()); _html = renderer.RenderBook(book).ToString(); File.WriteAllText("SupportedMarkdown.html", _html); }
private void ReloadBtn_Click(object sender, RoutedEventArgs e) { if (BookLoading) { return; } BookLoading = true; CacheStateStory.Begin(); BookLoader BL = new BookLoader(BookLoadComplete); BL.Load(ThisBook); BL.LoadIntro(ThisBook); }
private async void CheckTiles() { PinErrored = false; PinManager PM = new PinManager(); await PM.SyncSettings(); if (PM.Policy == PinPolicy.DO_NOTHING) { return; } ActiveItem[] MissingPins = PM.GetLocalPins().Where( x => !Windows.UI.StartScreen.SecondaryTile.Exists(x.Payload) ).ToArray(); if (0 < MissingPins.Length) { switch (PM.Policy) { case PinPolicy.ASK: bool RemoveRecord = true; StringResources stx = StringResources.Load("Message", "AppBar", "ContextMenu"); await Popups.ShowDialog(UIAliases.CreateDialog( string.Format(stx.Str("MissingPins"), MissingPins.Length) , () => RemoveRecord = false , stx.Text("PinToStart", "ContextMenu"), stx.Text("PinPolicy_RemoveMissing", "AppBar") )); if (RemoveRecord) { goto case PinPolicy.REMOVE_MISSING; } goto case PinPolicy.PIN_MISSING; case PinPolicy.PIN_MISSING: foreach (ActiveItem Item in MissingPins) { BookItem Book = await ItemProcessor.GetBookFromId(Item.Desc); if (Book == null) { PinError(); } else { TaskCompletionSource <string> TileId = new TaskCompletionSource <string>(); BookLoader Loader = new BookLoader(async(b) => { TileId.SetResult(b == null ? null : await PageProcessor.PinToStart(b)); }); Loader.Load(Book, true); await TileId.Task; } } break; case PinPolicy.REMOVE_MISSING: PM.RemovePin(MissingPins.Remap(x => x.Desc)); break; } } }