<commit_before>﻿using System;
using AngleSharp;

namespace ConsoleInteraction
{
    class Samples
    {
        public static void RunAll()
        {
            First();
        }

        static void First() 
        {
            var document = DocumentBuilder.Html("<h1>Some example source</h1><p>This is a paragraph element");
            //Do something with document like the following

            Console.WriteLine("Serializing the (original) document:");
            Console.WriteLine(document.ToHtml());

            var p = document.CreateElement("p");
            p.TextContent = "This is another paragraph.";

            Console.WriteLine("Inserting another element in the body ...");
            document.Body.AppendChild(p);

            Console.WriteLine("Serializing the document again:");
            Console.WriteLine(document.ToHtml());
        }
    }
}<commit_msg>Added some new samples in the playground<commit_after>﻿using System;
using System.Linq;
using AngleSharp;

namespace ConsoleInteraction
{
    class Samples
    {
        public static void RunAll()
        {
            First();
            UsingLinq();
            SingleElements();
        }

        static void First() 
        {
            var document = DocumentBuilder.Html("<h1>Some example source</h1><p>This is a paragraph element");
            //Do something with document like the following

            Console.WriteLine("Serializing the (original) document:");
            Console.WriteLine(document.ToHtml());

            var p = document.CreateElement("p");
            p.TextContent = "This is another paragraph.";

            Console.WriteLine("Inserting another element in the body ...");
            document.Body.AppendChild(p);

            Console.WriteLine("Serializing the document again:");
            Console.WriteLine(document.ToHtml());
        }

        static void UsingLinq()
        {
            var document = DocumentBuilder.Html("<ul><li>First item<li>Second item<li class='blue'>Third item!<li class='blue red'>Last item!</ul>");

            //Do something with LINQ
            var blueListItemsLinq = document.All.Where(m => m.TagName == "li" && m.ClassList.Contains("blue"));

            //Or directly with CSS selectors
            var blueListItemsSelector = document.QuerySelectorAll("li.blue");

            Console.WriteLine("Comparing both ways ...");

            Console.WriteLine();
            Console.WriteLine("LINQ:");

            foreach (var item in blueListItemsLinq)
                Console.WriteLine(item.ToText());

            Console.WriteLine();
            Console.WriteLine("CSS:");

            foreach (var item in blueListItemsLinq)
                Console.WriteLine(item.ToText());
        }

        static void SingleElements()
        {
            var document = DocumentBuilder.Html("<b><i>This is some <em> bold <u>and</u> italic </em> text!</i></b>");
            var emphasize = document.QuerySelector("em");

            Console.WriteLine("Difference between several ways of getting text:");
            Console.WriteLine();
            Console.WriteLine("Only from C# / AngleSharp:");
            Console.WriteLine();
            Console.WriteLine(emphasize.ToHtml());   //<em> bold <u>and</u> italic </em>
            Console.WriteLine(emphasize.ToText());   //boldanditalic

            Console.WriteLine();
            Console.WriteLine("From the DOM:");
            Console.WriteLine();
            Console.WriteLine(emphasize.InnerHTML);  // bold <u>and</u> italic
            Console.WriteLine(emphasize.OuterHTML);  //<em> bold <u>and</u> italic </em>
            Console.WriteLine(emphasize.TextContent);// bold and italic 
        }
    }
}
{'fraction_non_alphanumeric': 0.12137486573576799, 'fraction_numerical': 0.0010741138560687433, 'mean_word_length': 2.0938538205980066, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7434033', 'n_tokens_mistral': 948, 'n_tokens_neox': 914, 'n_words': 231}