allow better customization of nreadability output from PocketSharp assembly
This commit is contained in:
@@ -53,20 +53,37 @@ namespace PocketSharp
|
||||
/// <returns></returns>
|
||||
public async Task<string> 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("<html><head></head><body><h1>HALLO</h1><p>was geht</p></body></html>");
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<!-- A reference to the entire .NET Framework is automatically included -->
|
||||
<Content Include="Resources\readability.css" />
|
||||
<EmbeddedResource Include="Resources\readability.css" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AttributeTransformationInput.cs" />
|
||||
|
||||
@@ -173,7 +173,7 @@ namespace NReadability
|
||||
/// <param name="readingStyle">Styling for the extracted article.</param>
|
||||
/// <param name="readingMargin">Margin for the extracted article.</param>
|
||||
/// <param name="readingSize">Font size for the extracted article.</param>
|
||||
private NReadabilityTranscoder(
|
||||
public NReadabilityTranscoder(
|
||||
bool dontStripUnlikelys,
|
||||
bool dontNormalizeSpacesInTextContent,
|
||||
bool dontWeightClasses,
|
||||
|
||||
Reference in New Issue
Block a user