<commit_before>﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using WikiClientLibrary.Client;
using WikiClientLibrary.Sites;

namespace WikiClientLibrary.Pages.Parsing
{

    /// <summary>
    /// Provides extension methods to <see cref="WikiSite"/> for parsing wikitext content into HTML.
    /// </summary>
    public static class WikiSiteExtensions
    {

        private static IDictionary<string, object?> BuildParsingParams(WikiSite site, ParsingOptions options)
        {
            var p = new Dictionary<string, object?>
            {
                {"action", "parse"},
                {"prop", "text|langlinks|categories|sections|revid|displaytitle|properties"},
                {"disabletoc", (options & ParsingOptions.DisableToc) == ParsingOptions.DisableToc},
                {"disableeditsection", (options & ParsingOptions.DisableEditSection) == ParsingOptions.DisableEditSection},
                {"disabletidy", (options & ParsingOptions.DisableTidy) == ParsingOptions.DisableTidy},
                {"preview", (options & ParsingOptions.Preview) == ParsingOptions.Preview},
                {"sectionpreview", (options & ParsingOptions.SectionPreview) == ParsingOptions.SectionPreview},
                {"redirects", (options & ParsingOptions.ResolveRedirects) == ParsingOptions.ResolveRedirects},
                {"mobileformat", (options & ParsingOptions.MobileFormat) == ParsingOptions.MobileFormat},
                {"noimages", (options & ParsingOptions.NoImages) == ParsingOptions.NoImages},
                {"effectivelanglinks", (options & ParsingOptions.EffectiveLanguageLinks) == ParsingOptions.EffectiveLanguageLinks},
            };<commit_msg>Use useskin instead of effectivelanglinks on MW 1.30+.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using WikiClientLibrary.Client;
using WikiClientLibrary.Sites;

namespace WikiClientLibrary.Pages.Parsing
{

    /// <summary>
    /// Provides extension methods to <see cref="WikiSite"/> for parsing wikitext content into HTML.
    /// </summary>
    public static class WikiSiteExtensions
    {

        private static IDictionary<string, object?> BuildParsingParams(WikiSite site, ParsingOptions options)
        {
            var p = new Dictionary<string, object?>
            {
                {"action", "parse"},
                {"prop", "text|langlinks|categories|sections|revid|displaytitle|properties"},
                {"disabletoc", (options & ParsingOptions.DisableToc) == ParsingOptions.DisableToc},
                {"disableeditsection", (options & ParsingOptions.DisableEditSection) == ParsingOptions.DisableEditSection},
                {"disabletidy", (options & ParsingOptions.DisableTidy) == ParsingOptions.DisableTidy},
                {"preview", (options & ParsingOptions.Preview) == ParsingOptions.Preview},
                {"sectionpreview", (options & ParsingOptions.SectionPreview) == ParsingOptions.SectionPreview},
                {"redirects", (options & ParsingOptions.ResolveRedirects) == ParsingOptions.ResolveRedirects},
                {"mobileformat", (options & ParsingOptions.MobileFormat) == ParsingOptions.MobileFormat},
                {"noimages", (options & ParsingOptions.NoImages) == ParsingOptions.NoImages},
            };
            if ((options & ParsingOptions.EffectiveLanguageLinks) == ParsingOptions.EffectiveLanguageLinks)
            {
                if (site.SiteInfo.Version.Above(1, 30, 0))
                    // https://github.com/wikimedia/mediawiki/commit/df5b122641bf047d8f5834d1f0c219769c3593c2
                    p["useskin"] = "apioutput";
                else
                    p["effectivelanglinks"] = "true";
            }
{'fraction_non_alphanumeric': 0.11302337528898022, 'fraction_numerical': 0.008990495761623427, 'mean_word_length': 3.0352331606217615, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 1, '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': '6955827', 'n_tokens_mistral': 1037, 'n_tokens_neox': 984, 'n_words': 195}