From 9c0cf6cb3aab51047f78e09b2410948ebb3a235c Mon Sep 17 00:00:00 2001 From: ceee Date: Tue, 15 Oct 2013 21:52:33 +0200 Subject: [PATCH] allow better customization of nreadability output from PocketSharp assembly --- PocketSharp/PocketReader.cs | 35 ++++++++++++++----- .../NReadability/NReadability.csproj | 2 +- .../NReadability/NReadabilityTranscoder.cs | 2 +- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/PocketSharp/PocketReader.cs b/PocketSharp/PocketReader.cs index 8074f00..13a6d38 100644 --- a/PocketSharp/PocketReader.cs +++ b/PocketSharp/PocketReader.cs @@ -53,20 +53,37 @@ namespace PocketSharp /// public async Task Read(Uri uri) { - NReadabilityTranscoder transcoder = new NReadabilityTranscoder(); + // initialize transcoder + NReadabilityTranscoder transcoder = new NReadabilityTranscoder( + dontStripUnlikelys: false, + dontNormalizeSpacesInTextContent: true, + dontWeightClasses: false, + readingStyle: ReadingStyle.Ebook, + readingMargin: ReadingMargin.Narrow, + readingSize: ReadingSize.Medium + ); + // get HTML string from URI string htmlResponse = await Request(uri); - TranscodingInput input = new TranscodingInput("

HALLO

was geht

"); - TranscodingResult result = transcoder.Transcode(input); + // set properties for processing + TranscodingInput transcodingInput = new TranscodingInput(htmlResponse) + { + Url = uri.ToString(), + DomSerializationParams = new DomSerializationParams() + { + PrettyPrint = true, + DontIncludeContentTypeMetaElement = true, + DontIncludeMobileSpecificMetaElements = true, + DontIncludeDocTypeMetaElement = true, + DontIncludeGeneratorMetaElement = true + } + }; - // //new TranscodingInput( - // //transcoder.Transcode( - // //string transcodedContent = - // // transcoder.Transcode("https://github.com/marek-stoj/NReadability", out success); + // process/transcode HTML + TranscodingResult transcodingResult = transcoder.Transcode(transcodingInput); - - return result.ExtractedContent; + return transcodingResult.ExtractedContent; } diff --git a/PortablePorts/NReadability/NReadability.csproj b/PortablePorts/NReadability/NReadability.csproj index b4cc528..1898b20 100644 --- a/PortablePorts/NReadability/NReadability.csproj +++ b/PortablePorts/NReadability/NReadability.csproj @@ -34,7 +34,7 @@ - + diff --git a/PortablePorts/NReadability/NReadabilityTranscoder.cs b/PortablePorts/NReadability/NReadabilityTranscoder.cs index 44426cc..130a18a 100644 --- a/PortablePorts/NReadability/NReadabilityTranscoder.cs +++ b/PortablePorts/NReadability/NReadabilityTranscoder.cs @@ -173,7 +173,7 @@ namespace NReadability /// Styling for the extracted article. /// Margin for the extracted article. /// Font size for the extracted article. - private NReadabilityTranscoder( + public NReadabilityTranscoder( bool dontStripUnlikelys, bool dontNormalizeSpacesInTextContent, bool dontWeightClasses,