Skip to content

GetInnerText is behaving different from HTML innerText for tables #174

@timothy3001

Description

@timothy3001

Prerequisites

  • Can you reproduce the problem in a MWE?
  • Are you running the latest version of AngleSharp.Css?
  • Did you check the FAQs to see if that helps you?
  • Are you reporting to the correct repository? (there are multiple AngleSharp libraries, e.g., AngleSharp.Xml for Xml support)
  • Did you perform a search in the issues?

Description

When using GetInnerText the result returned misses linebreaks for the table rows.

If I use HTMLs "innerText", the linebreaks after each tablerow are correct.

I also tried to add "
" after a "" element, but it is ignored. Everything between "" and "" seems to be ignored.

Thanks a lot for the awesome project!

Steps to Reproduce

Setup simple Anglesharp example, config like the following:

IConfiguration config = Configuration
    .Default
    .WithCss(new CssParserOptions
    {
        IsToleratingInvalidSelectors = true,
        IsIncludingUnknownDeclarations = true,
        IsIncludingUnknownRules = true,
    })
    .WithRenderDevice(new DefaultRenderDevice
    {
        DeviceHeight = 768,
        DeviceWidth = 1024,
        
    });

Then parse the following HTML:

<html>
	<head>
	</head>
	<body>
		<h2>Test</h2>
		<table>
			<tbody>
				<tr>
				</tr>
				<tr>
					<td>Titel: </td>
					<td>Herr</td>
				</tr>
				<tr>
					<td>Vorname: </td>
					<td>Horst</td>
				</tr>
				<tr>
					<td>Nachname: </td>
					<td>Hammer</td>
				</tr>
			</tbody>
		</table>
	</body>
</html>

Expected Behavior

The result when going with document.body.innerText from Chrome devtools console:

Test

Titel:	Herr
Vorname:	Horst
Nachname:	Hammer

Actual Behavior

The result from anglesharp GetInnerText:

Test





Titel: Herr Vorname: Horst Nachname: Hammer 

Possible Solution / Known Workarounds

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions