شعار Wikipedia Wikitables

Wikipedia Wikitables

المجتمع
fuzheado
wikipedia-wikitables

Create, parse, style, and fix MediaWiki wikitable syntax — delimiters, header/data cells, CSS classes, inline styling, rowspan/colspan, accessibility attributes, sortable and collapsible tables, and programmatic table generation from data

نظرة عامة

الناشرfuzheado
المستودعWikipedia-AI-Skills
اسم المهارةwikipedia-wikitables
النجوم
27
التفريعات
10
الملفات المرفقة
4
الترخيصMIT
الروابط
  • تعليمات بصيغة Markdown

    ملف SKILL.md يُحمّله النموذج عند الحاجة، فلا يستهلك توكنات إلا عندما يَرِد طلب ذو صلة فعلًا.

  • تعمل مع أي نموذج لغوي كبير

    مهارات الذكاء الاصطناعي مكتوبة بصيغة Markdown وليست شيفرة خاصة بمزوّد معيّن، لذا تعمل مع GPT أو Claude أو Gemini أو Grok أو نموذج محلي.

  • الملفات المرفقة: 4

    نصوص برمجية وقوالب ومراجع يمكن للنموذج قراءتها أثناء عمله. الملفات للقراءة فقط ولا تُنفّذ أبدًا.

  • مفتوحة المصدر

    نشرها fuzheado على GitHub. اطّلع على المصدر قبل تثبيتها.

التثبيت

ثبّت مهارة الذكاء الاصطناعي Wikipedia Wikitables في TypingMind لاستخدامها مع أي نموذج لغوي كبير، أو أضفها إلى وكيل ذكاء اصطناعي آخر يقرأ SKILL.md.

1

التثبيت في TypingMind

يُثبّت TypingMind المهارة مباشرةً من مجلدها على GitHub — فيقرأ SKILL.md، ويجمع ملفات الموارد في حزمة، ويحفظ النتيجة محليًا.

  1. افتح التطبيق وانتقل إلى «الإضافات» ثم «المهارات».
  2. اختر «تثبيت من GitHub».
  3. الصق رابط مجلد المهارة الموضّح أدناه وأكّد التثبيت.
    https://github.com/fuzheado/Wikipedia-AI-Skills/tree/main/.claude/skills/wikipedia-wikitables
  4. فعّل المهارة في كل محادثة تريد إتاحتها فيها.
الإضافات ← المهارات ← إضافة مهارة ← من رابط GitHub، ثم الصق رابط المجلد واضغط على «متابعة».
2

التثبيت في وكيل ذكاء اصطناعي آخر

يمكن لأي وكيل ذكاء اصطناعي يقرأ تنسيق Agent Skills استخدام هذه المهارة — انسخ المجلد إلى مجلد المهارات الخاص بذلك الوكيل.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/fuzheado/Wikipedia-AI-Skills.git /tmp/Wikipedia-AI-Skills
mkdir -p .claude/skills
cp -r /tmp/Wikipedia-AI-Skills/.claude/skills/wikipedia-wikitables .claude/skills/wikipedia-wikitables
أعد تشغيل Claude Code بعد النسخ ليتعرّف على المهارة الجديدة.

استخدمها في TypingMind

فعّل Wikipedia Wikitables في أي محادثة على TypingMind وسيتولى النموذج الباقي. تتضمن مطالبة النظام اسمها ووصفها، وبمجرد ورود طلب ذي صلة، يُحمّل النموذج التعليمات الكاملة تلقائيًا — فلا تحتاج إلى استدعائها يدويًا، ولا تستهلك أي توكنات حتى تُستخدم فعليًا.

يُحمّل النموذج مهارة Wikipedia Wikitables تلقائيًا بمجرد ورود طلب ذي صلة بها.

تعمل مع أي نموذج ذكاء اصطناعي

مهارات الذكاء الاصطناعي هي تعليمات بصيغة Markdown وليست شيفرة خاصة بمزوّد معيّن، لذا لا ترتبط Wikipedia Wikitables بالنموذج الذي كُتبت له. ثبّتها مرة واحدة في TypingMind واستخدمها مع GPT-5 أو Claude أو Gemini أو Grok أو DeepSeek أو Mistral أو Llama أو نموذج محلي تشغّله بنفسك — كل ذلك باستخدام مفاتيح API الخاصة بك.

  • تُحمَّل عند الحاجة فقط

    تتضمن مطالبة النظام الاسم والوصف فقط. وتُجلب التعليمات عند أول طلب ذي صلة، لذا لا تستهلك تعليمات المهارة أي توكنات ما دامت المهارة غير مستخدمة.

  • بدّل النماذج أثناء المحادثة

    لأن المهارة تعليمات وليست شيفرة، فإن تغيير النموذج لا يعطّلها — فالنموذج التالي يقرأ ملف SKILL.md نفسه.

تعليمات المهارة

هذا هو محتوى SKILL.md الذي يُحمّله النموذج. اقرأه قبل التثبيت — فالمهارة عبارة عن تعليمات سيتبعها نموذجك.

⚠️ Prerequisite: This skill assumes basic familiarity with wikitext templates. See wikipedia-templates for template syntax, and wikimedia-wikitext for AST parsing with mwparserfromhell.

⚠️ User-Agent required: API calls to fetch wikitext or render tables need a descriptive User-Agent header. See the wikimedia-api-access skill for the correct format.


Reference: Wikitable Building Blocks

MediaWiki tables use a pipe-based syntax inspired by HTML table markup. Every table has four structural delimiters:

SymbolMeaningOpens/ClosesHTML equivalent
{|Table openStart of table<table>
|}Table closeEnd of table</table>
|-Row separatorNew row<tr>
|Data cellCell content<td>
!Header cellHeader content<th>
|+CaptionTable caption<caption>

Minimal Complete Table

wikitext
{| class="wikitable"
|+ Annual revenue
! Year
! Revenue
|-
| 2020
| $1.2M
|-
| 2021
| $1.8M
|}

This renders as a single row of headers (!) followed by two data rows (|).

Anatomy of a Cell

A cell can have attributes (class, style, scope, colspan, rowspan) before the content. The pipe separates attributes from the value:

wikitext
| style="text-align: center;" | centered content
! scope="col" style="text-align: right;" | Header
| rowspan="2" | spans two rows

The general pattern is:

| [attribute1] [attribute2] ... | cell content

Multiple attributes on the same cell are space-separated between the opening pipe and the final | that precedes the content.


SOP: Class-Based Styling

MediaWiki's common.css ships with pre-defined table classes. You apply them on the table-open line:

wikitext
{| class="wikitable"

Available Classes

ClassEffectNotes
wikitableStandard styling: light gray header, borders, striped rowsThe default for most tables
sortableAdds clickable column headers for sortingMust be combined with wikitable or another base class
mw-collapsibleAdds a [show]/[hide] toggleUsed in navboxes and data tables
mw-collapsedStarts collapsed (requires mw-collapsible)Content hidden by default
mw-datatableAlternating row colors, hover highlightUsed by software/database tables
plainlinksRemoves external link icons inside the tableUseful in infobox-style tables

Common Combinations

wikitext
{| class="wikitable sortable"
! Name
! Score
!
|-
| Alice
| 95
|}
wikitext
{| class="wikitable sortable mw-collapsible mw-collapsed"
! Hidden by default, click to expand
|-
| Revealed content
|}

Row-Level Classes

Classes can also go on the row separator:

wikitext
|- class="sortbottom"
| Total
| $3.0M

class="sortbottom" pins a summary row to the bottom of a sortable table, preventing it from being sorted with the data rows.


SOP: Inline CSS Styling

For fine-grained control beyond what the built-in classes provide, use inline style= attributes at the table, row, or cell level.

Table-Level Styles

wikitext
{| class="wikitable" style="width: 100%; background-color: #f8f9fa;"
StyleEffectWhen to Use
width: 100%;Full-width tableDashboard/report tables
width: auto;Shrink to contentSmall lookup tables
background-color: #f8f9fa;Light gray backgroundSubtle table backdrop
border-collapse: collapse;Single borders instead of double(Default for wikitable)
margin-left: auto; margin-right: auto;Center the table on the pageStandalone tables
font-size: 90%;Slightly smaller textSidebar/compact tables

Row-Level Styles

wikitext
|- style="background-color: #efe;"
| Highlighted row

Useful for section breaks, totals, or status indicators (e.g. green for "approved", red for "fails").

Cell-Level Styles

wikitext
| style="text-align: center;" | Centered
| style="text-align: right; font-weight: bold;" | Right-aligned bold
! style="text-align: left; background-color: #eaecf0;" | Left header

Text Alignment

StyleEffect
text-align: left;Left-align content
text-align: center;Center content
text-align: right;Right-align content
text-align: justify;Justified text
vertical-align: top;Align to top of cell
vertical-align: middle;Vertically center
vertical-align: bottom;Align to bottom of cell

Background Colors

wikitext
! scope="col" style="background-color: #cfe3ff;" | Blue header
|- style="background-color: #ffffcc;"
| Yellow row
| style="background-color: #fee;" | Pink cell

Borders and Spacing

wikitext
{| style="border: 2px solid #a3bfb1;"
|- style="border-bottom: 3px solid #a3bfb1;"
| style="border-right: 1px dashed #ccc;" | Content
|}

{| style="cellpadding: 10px;"
|- style="padding: 8px;"
| Spacious cell
|}

Legacy HTML Attributes (avoid in new tables)

Older tables use HTML attributes like align=, valign=, bgcolor=. These still render but are deprecated in HTML5. Prefer CSS style=:

LegacyModern CSS equivalent
align="center"style="text-align: center;"
valign="top"style="vertical-align: top;"
bgcolor="#eee"style="background-color: #eee;"
width="500"style="width: 500px;"
border="1"style="border: 1px solid #a2a9b1;"

Shorthand Multi-Value Attributes

You can combine multiple styles on one cell:

wikitext
| style="text-align: right; background-color: #fdd; white-space: nowrap; font-size: 90%;" | 42

SOP: Accessibility with scope

For screen readers, header cells must specify which cells they govern:

wikitext
! scope="col" | Column header
! scope="col" | Another header
! scope="row" | Row header
scope valueMeaning
scope="col"Header applies to the column below it
scope="row"Header applies to the row beside it
scope="colgroup"Header applies to a group of columns
scope="rowgroup"Header applies to a group of rows

A table with class="wikitable" and proper scope attributes passes WCAG accessibility requirements. A table with no scope does not.


SOP: Column Spans and Row Spans

wikitext
! colspan="2" | Merged header spanning two columns
| rowspan="3" | Content spans three rows
| colspan="2" rowspan="2" | Spans both
  • colspan="N" — merge N columns horizontally
  • rowspan="N" — merge N rows vertically
  • Can be combined on the same cell
  • Cells covered by a span are omitted (not written with empty | |)

Common Patterns

wikitext
{| class="wikitable"
! colspan="2" | Merged header
! scope="col" | Single
|-
! scope="row" | Row header
| Data 1
| Data 2
|-
| rowspan="2" | Vertical span
| A
| B
|-
| C
| D
|}

SOP: Inline Cell Content

Cell values support any wikitext — templates, links, images, lists, even nested tables:

wikitext
| [[Albert Einstein]] (born 1879)
| {{flag|France}}
| [[File:Example.jpg|50px]]
|
* Item one
* Item two
|
{| class="wikitable"
| Nested table
|}

SOP: Parsing Tables with mwparserfromhell

python
import mwparserfromhell

wikitext = """{| class="wikitable sortable"
! Name
! Score
! scope="col" | Rank
|-
| Alice
| 95
| style="text-align: center;" | 1st
|}"""

parsed = mwparserfromhell.parse(wikitext)
tables = parsed.filter_tags(matches=lambda t: str(t.tag) == "table")

for table in tables:
    print("Table:", table)
    # Extract attributes
    if table.has("class"):
        print("  Classes:", table.get("class").value)

For extracting structured data from tables, use the style and class attributes to identify header rows and data cells.


SOP: Generating Tables from Data (Python)

python
def dicts_to_wikitable(
    data: list[dict[str, str]],
    *,
    classes: str = "wikitable sortable",
    caption: str = "",
    alignment: str | None = None,
) -> str:
    """Convert a list of dicts to a MediaWiki wikitable string."""
    if not data:
        return ""

    headers = list(data[0].keys())
    style = f' style="text-align: {alignment};"' if alignment else ""
    lines: list[str] = []
    lines.append(f'{{| class="{classes}"{style}')
    if caption:
        lines.append(f"|+ {caption}")
    lines.append("! " + "\n! ".join(f'scope="col" | {h}' for h in headers))
    for row in data:
        lines.append("|-")
        for h in headers:
            val = row.get(h, "")
            # Auto-align numeric values to the right
            try:
                float(val.replace(",", "").replace("$", "").replace("%", ""))
                cell = f' style="text-align: right;" | {val}'
            except ValueError:
                cell = f"| {val}"
            lines.append(cell)
    lines.append("|}")
    return "\n".join(lines)


# Example
data = [
    {"Name": "Alice", "Score": "95"},
    {"Name": "Bob", "Score": "87"},
]
print(dicts_to_wikitable(data, caption="Scores"))

SOP: Failure Modes & Render Verification

❌ Anti-pattern: single-line tables (common LLM generation bug)

A table written entirely on one line does not render:

wikitext
{| class="wikitable" ! Date !! Article !! Status |- | Jan 12 || [[X]] || start |- | Feb 2 || [[Y]] || start |}

MediaWiki table syntax is line-based: the markers {| (open), ! (header row start), |- (row separator), | (first cell of a row) and |} (close) are only recognized at the start of a line. The only valid inline separators are || (between cells) and !! (between header cells).

Verified failure behavior (2026-08-18, enwiki): a 5-table page with all tables single-line rendered as one empty table (<tr><td></td></tr>) with the other four silently lost — no error message, no leaked markup. The first {| opens a table that swallows content until a line-start |}, which never comes; the rest is dropped.

✅ Correct structure — every marker at a line start:

wikitext
{| class="wikitable"
! Date !! Article !! Status
|-
| Jan 12 || [[X]] || start
|-
| Feb 2 || [[Y]] || start
|}

✅ Render-test SOP — always verify with the real parser

Client-side previews (including the rough script in Tooling below) are approximations; MediaWiki's line-based parser is the authority. Verify by parsing the wikitext through the API and asserting the structure:

  1. POST the wikitext to action=parse — GET overflows (HTTP 414) on anything beyond a tiny table:
    bash
    curl -s -A "$WIKIMEDIA_USER_AGENT" -X POST "https://en.wikipedia.org/w/api.php" \
      --data-urlencode "action=parse" --data-urlencode "prop=text" \
      --data-urlencode "format=json" --data-urlencode "title=Sandbox" \
      --data-urlencode "contentmodel=wikitext" --data-urlencode "text@wikitable.txt" \
      | python3 -c "import json,sys; print(json.load(sys.stdin)['parse']['text']['*'])"
  2. Assert the structure of the rendered HTML:
    • <table class="wikitable"> count == expected number of tables
    • <tr> count == header rows + data rows (a mismatch means content was swallowed or rows merged)
    • <th> count == tables × columns
    • no empty table — <tr><td></td></tr> signals the single-line trap
    • no escaped table-open — &#123;| in the HTML means a {| was treated as literal text, i.e. the table never opened
  3. Spot-check that key wikilinks (<a href="/wiki/...">) survived.

LLM-generation checklist

  • {| / |} / |- each on their own line
  • Header row and every data row start at a line start (! / |)
  • || / !! used only within a row
  • After generating, always run the render-test above before shipping the page

Reference: Styling Quick Reference

Color Palette (Wikimedia Standard)

These are the colors used by class="wikitable" and common in Wikipedia tables:

ColorHexUse
Table header background#eaecf0Default wikitable header
Table body background#f8f9faDefault wikitable body
Alternating row highlight#fafafaHover/alternate shade
Border#a2a9b1Default table border
Green row (pass)#d5fdf4Positive signal
Yellow row (warning)#fef6e7Needs attention
Red row (fail/error)#fee7e6Negative signal
Blue header#cfe3ffCustom header color

Alignment Summary

TargetInline StyleClass Alternative
Center the table on pagestyle="margin:0 auto;"Not available as class
Left-align a columnstyle="text-align: left;"Not available as class
Center a columnstyle="text-align: center;"Not available as class
Right-align numeric columnstyle="text-align: right;"Not available as class
Vertically center cellsstyle="vertical-align: middle;"Not available as class
Pin a row to bottom—class="sortbottom"

Reference: When to Use Which Approach

SituationApproachExample
Standard data tableClass onlyclass="wikitable sortable"
Report with a color-coded rowClass + inlineclass="wikitable", |- style="background: #fee;"
One-off alignment overrideInline cell style| style="text-align: center;" | 42
Table for user scripts/gadgetsClass + accessibleclass="wikitable" + scope="col" on all headers
Compact sidebar tableInline table stylestyle="font-size: 90%; width: auto;"

Tooling

🔧 Wikitable to HTML Preview (scripts/wikitable-to-html.sh)

Convert a wikitable to rough HTML for visual verification:

⚠️ Rough preview only — it cannot reproduce MediaWiki's line-based parsing quirks (single-line tables, swallowed content). Always confirm with the render-test SOP above before publishing.

bash
echo '{| class="wikitable"|! A|! B|-|1|2|}' | ./scripts/wikitable-to-html.sh

🔧 Generate Table from CSV (scripts/generate-table.sh)

bash
cat data.csv | ./scripts/generate-table.sh --caption "Scores" --classes "wikitable sortable"

🐍 Wikitable Tools (assets/wikitable_tools.py)

python
from assets.wikitable_tools import (
    dicts_to_wikitable,
    parse_wikitable,
    style_cell,
)

# Generate
table = dicts_to_wikitable(data, caption="Results", alignment="center")

# Parse
rows = parse_wikitable(wikitext)

# Style a single cell
styled = style_cell("42", align="right", bold=True, background="#efe")

🐍 Test Suite (assets/test_wikitable_tools.py)

bash
python3 -m pytest assets/test_wikitable_tools.py -v

Tests cover: generation from dicts, parsing, styling, edge cases (empty tables, colspan, rowspan, nested tables, multi-word headers, numeric auto-alignment).


Cross-References

Related SkillWhy
wikimedia-wikitextAST-based wikitext parsing — never parse tables with regex
wikipedia-templatesTable-generating templates and template-based table styling
wikipedia-page-anatomyTables as article body elements — structure and placement
wikimedia-api-accessUser-Agent and API patterns

الملفات المرفقة

يقرأ النموذج هذه الملفات عند الحاجة ما دامت المهارة محمّلة. وهي متاحة للقراءة ولا تُنفّذ أبدًا.

الأسئلة الشائعة

ماذا تفعل مهارة الذكاء الاصطناعي Wikipedia Wikitables؟

Create, parse, style, and fix MediaWiki wikitable syntax — delimiters, header/data cells, CSS classes, inline styling, rowspan/colspan, accessibility attributes, sortable and collapsible tables, and programmatic table generation from data

لماذا تستخدم Wikipedia Wikitables على TypingMind؟

لأنك تثبّتها مرة واحدة وتستخدمها مع أي نموذج. مهارة Wikipedia Wikitables عبارة عن نص Markdown وليست شيفرة خاصة بمزود بعينه، لذا تعمل المهارة نفسها مع GPT-5 أو Claude أو Gemini أو Grok أو نموذج محلي، ويمكنك تبديل النموذج أثناء المحادثة دون تعطّل المهارة. يعمل TypingMind بمفاتيح API الخاصة بك، فتدفع للمزودين مباشرةً بدلًا من اشتراك لكل مقعد، وتبقى مهاراتك ومحادثاتك في مساحة التخزين الخاصة بك.

كيف أثبّت Wikipedia Wikitables في TypingMind؟

في TypingMind، افتح «الإضافات»، ثم «المهارات»، ثم اختر «التثبيت من GitHub» والصق https://github.com/fuzheado/Wikipedia-AI-Skills/tree/main/.claude/skills/wikipedia-wikitables. يقرأ TypingMind ملف SKILL.md الخاص بالمهارة، ويجمع ملفاتها ويثبّتها كمهارة يمكنك تفعيلها لكل محادثة على حدة.

ما نماذج الذكاء الاصطناعي التي يمكنها استخدام Wikipedia Wikitables؟

أي نموذج تربطه في TypingMind. مهارات الذكاء الاصطناعي عبارة عن تعليمات Markdown وليست شيفرة خاصة بمزود بعينه، لذا يمكن لكل من GPT وClaude وGemini وGrok والنماذج المحلية تحميل هذه المهارة عندما يتوافق الطلب معها.

كم نموذج ذكاء اصطناعي يمكنني استخدامه مع Wikipedia Wikitables؟

أي عدد تريده. ما دام النموذج يدعم المهارات، يمكنك استخدام Wikipedia Wikitables معه، سواء كان GPT أو Claude أو Gemini أو Grok أو DeepSeek أو Mistral أو Llama أو غيرها، وكل ذلك على TypingMind باستخدام مفاتيح API الخاصة بك.

هل مهارة الذكاء الاصطناعي Wikipedia Wikitables مجانية؟

نعم. نشرها fuzheado على GitHub بموجب ترخيص MIT. لا تدفع إلا لمزود الذكاء الاصطناعي الخاص بك مقابل التوكنات التي تستخدمها.

ما هي مهارات الذكاء الاصطناعي؟

مهارة الذكاء الاصطناعي حزمة تعليمات قابلة لإعادة الاستخدام تعلّم نموذج الذكاء الاصطناعي كيفية تنفيذ مهمة محددة. وتتبع تنسيق Agent Skills المفتوح: ملف SKILL.md يتضمن اسمًا ووصفًا، إلى جانب أي نصوص برمجية أو قوالب أو ملفات مرجعية قد يحتاج إليها النموذج. لا يقرأ النموذج التعليمات إلا عندما يتوافق طلبك مع المهارة، لذا لا تترتب على المهارة المثبتة أي تكلفة حتى تُستخدم.

كيف تختلف مهارات الذكاء الاصطناعي عن الإضافات أو موصلات MCP؟

تمنح الإضافة أو موصل MCP النموذج أدوات جديدة يمكنه استدعاؤها، وهي شيفرة تُنفَّذ في مكان ما وتُرجع نتيجة. أما مهارة الذكاء الاصطناعي فتزوّد النموذج بالمعرفة ومنهجية العمل: كيفية التعامل مع مهمة، والخطوات التي ينبغي اتباعها، وما ينبغي أن تكون عليه المخرجات الجيدة. المهارات عبارة عن نصوص Markdown، لذا لا تحتاج إلى خادم أو مفتاح API أو بيئة تشغيل، وتعمل مع أي نموذج.

عرض الكل

أنشئ مساحة عملك للذكاء الاصطناعي الآن

اشترك في نشرتنا الإخبارية لتصلك أخبار الميزات الجديدة والهدايا القادمة 👇