diff --git a/src/content/docs/creating-custom-feeds.mdx b/src/content/docs/creating-custom-feeds.mdx index 6a0ffcea..fcff59eb 100644 --- a/src/content/docs/creating-custom-feeds.mdx +++ b/src/content/docs/creating-custom-feeds.mdx @@ -109,7 +109,7 @@ Example metadata: lang="yaml" /> -Allowed topics: `sports`, `energy`, `tech`, `science`, `news`, `entertainment`, `jobs`, `finance`, `security`, `travel`, `environment`, `consumer`, `civic`, `product`, `research`. +Allowed topics: `sports`, `energy`, `tech`, `science`, `news`, `entertainment`, `jobs`, `finance`, `security`, `travel`, `environment`, `consumer`, `civic`, `product`, `research`, `health`, `culture`, `education`, `rights`, `transport`. ## Next diff --git a/src/content/docs/get-involved/contributing.mdx b/src/content/docs/get-involved/contributing.mdx index 5c13db80..38698a78 100644 --- a/src/content/docs/get-involved/contributing.mdx +++ b/src/content/docs/get-involved/contributing.mdx @@ -55,7 +55,13 @@ Are you a Ruby developer? You can help us improve the core `html2rss` gem. Wheth [**Check out the documentation for the `html2rss` Gem**](/ruby-gem/) -### 5. Report Bugs & Discuss Features +### 5. Help Improve a Language + +Native speaker? `html2rss` reads page words like "read more" and "sponsored" in 29 languages, and those word lists need review. Fix a word list with the Edit button on GitHub and open a pull request. No setup needed. + +[**See how in Language Support**](/ruby-gem/reference/language-support/#help-improve-a-language) + +### 6. Report Bugs & Discuss Features If you've found a bug, please open an issue on the appropriate GitHub repository. For new feature ideas, we encourage you to start a discussion first. diff --git a/src/content/docs/ruby-gem/reference/auto-source.mdx b/src/content/docs/ruby-gem/reference/auto-source.mdx index 8569db9e..eb8ec5c5 100644 --- a/src/content/docs/ruby-gem/reference/auto-source.mdx +++ b/src/content/docs/ruby-gem/reference/auto-source.mdx @@ -51,6 +51,19 @@ Drop reasons (counts) land on `Html2rss::Status#admission_drops`. Print them wit Ruby `limit:` and CLI `--limit` cap kept articles (default `25`). +**Dates from URL paths.** When an item has no date from any other source, html2rss uses a date in its URL if the path holds exactly one unambiguous date, such as `/2023/01/02/story` or `/2023-01-02-story`. The item gets midnight of that day in your [`channel.time_zone`](/ruby-gem/reference/channel/#dates-without-a-time-zone). Bare numeric ids, paths without a day (`/2020/06/88083`) and a bare `/2024/01/01/` give no date. With [`enrich`](/ruby-gem/reference/configuration/#per-feed-option-enrich) on, a date from the article page wins. + +### What gets kept and merged + +html2rss then filters the items before they reach the feed: + +- **Non-article pages are dropped.** Links to section indexes, profile pages, bare media file routes and similar non-story destinations never become items. +- **Copies of one article merge into one item.** Links that differ only by `http` versus `https`, a trailing slash, a fragment, or a tracking parameter count as the same article. So do links that differ only by a placement parameter (for example `?pos=top` and `?pos=latest`), which html2rss recognizes from how the page repeats it. The first copy keeps its fields; later copies fill only what it lacks. +- **The main list beats sidebars.** On card-grid front pages, the main article list ranks above sidebars and topical modules. +- **Other drops.** Sponsored items, links to other domains, untitled items, titles under three words and junk titles are dropped. `keep_sponsored` and `keep_different_domain` in [Cleanup Options](#cleanup-options) opt out of the first two. `--explain` shows the counts. + +Words like "read more" or "advertisement" are matched in the page's language. See [Language support](/ruby-gem/reference/language-support/). + **`json_state` / `xhr_articles`:** both need discoverable arrays of hashes with clear `title` and `url` fields. Minified or obfuscated payloads, heavily encoded values, or blobs that require executing embedded functions are ignored. `xhr_articles` only sees JSON bodies captured during the current Botasaurus browser scrape (capped by the scrape API). **`wordpress_api`:** depends on a public WordPress REST API root. The scraper fetches post records directly; it does not resolve category names or featured media metadata. diff --git a/src/content/docs/ruby-gem/reference/channel.mdx b/src/content/docs/ruby-gem/reference/channel.mdx index b8572fee..bb1721da 100644 --- a/src/content/docs/ruby-gem/reference/channel.mdx +++ b/src/content/docs/ruby-gem/reference/channel.mdx @@ -33,21 +33,37 @@ This example is a complete feed config so you can see the `channel` block in con ## Options -| Attribute | Required | Description | -| :------------ | :----------- | :--------------------------------------------------------------------------------------------------------------------------------------- | -| `url` | **Required** | The URL of the website to scrape. | -| `title` | Optional | The title of the RSS feed. Defaults to the website's title. | -| `description` | Optional | A description for the RSS feed. Defaults to the website's meta description. | -| `author` | Optional | The author of the feed, in the format `email (Name)`. | -| `ttl` | Optional | The "time to live" for the feed in minutes. Defaults to the `max-age` from the response headers, or `360`. | -| `language` | Optional | The language of the feed. Defaults to the `lang` attribute of the `` tag. | -| `time_zone` | Optional | The time zone for parsing dates. See the [list of tz database time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). | +| Attribute | Required | Description | +| :------------ | :----------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `url` | **Required** | The URL of the website to scrape. | +| `title` | Optional | The title of the RSS feed. Defaults to the website's title. | +| `description` | Optional | A description for the RSS feed. Defaults to the website's meta description. | +| `author` | Optional | The author of the feed, in the format `email (Name)`. | +| `ttl` | Optional | The "time to live" for the feed in minutes. Defaults to the `max-age` from the response headers, or `360`. | +| `language` | Optional | The language of the feed. Defaults to the `Content-Language` header, then the `lang` attribute of the `` tag. See [Language support](/ruby-gem/reference/language-support/). | +| `time_zone` | Optional | The time zone for dates that state none. See the [list of tz database time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). | ## Notes - `language` is runtime-validated. Use a valid language code such as `en`, not an arbitrary string. - `author` should follow the RSS-style `email (Name)` format when you set it explicitly. The RSS `managingEditor` element is written only when `author` is an email address (`editor@example.com` or `editor@example.com (Name)`); a plain name is omitted from `managingEditor`. -- `time_zone` must be a known TZ database identifier such as `UTC` or `Europe/Berlin`. +- `time_zone` should be a TZ database identifier such as `UTC` or `Europe/Berlin`. An unknown or missing zone reads as `UTC`. + +## Dates without a time zone + +Many pages print a date like `2025-03-04 18:30` with no zone. With `auto_source`, html2rss reads such a date in your `channel.time_zone`. This holds for HTML pages and for structured data: JSON-LD, Microdata, embedded JSON and sitemaps. WordPress posts use their exact UTC time. + +A date that names a zone, such as `GMT` or `EST`, keeps its real instant and is not shifted. + + --- diff --git a/src/content/docs/ruby-gem/reference/configuration.mdx b/src/content/docs/ruby-gem/reference/configuration.mdx index 5d4b53f2..9ce8b6ce 100644 --- a/src/content/docs/ruby-gem/reference/configuration.mdx +++ b/src/content/docs/ruby-gem/reference/configuration.mdx @@ -140,6 +140,31 @@ Specifies a custom formatter for the default logger. This must be a callable obj lang="ruby" /> +## Per-feed option: `enrich` + +`enrich` is not a `Html2rss.configure` option. Set it at the top level of a feed config. + +Listing pages often lack a date, author or image. With `enrich` on, html2rss fetches each item's own page and fills in only what is missing. It reads the page's JSON-LD (`author`, `datePublished`) and meta tags (`og:image`, `article:published_time`, `article:author`). + + + +- **Opt-in.** Nothing is fetched unless `article_metadata` is `true`. +- **Fill only.** A value found on the listing is never overwritten. A date from the article page wins over a date guessed from the URL. Titles, descriptions and body text are never touched. +- **Extra requests.** A build makes up to `max_fetches` additional requests (`1` to `10`) with the same request strategy. They do not use up `request.max_requests`; the two limits add up. +- **Same site only.** Links to other origins are skipped. A failed or blocked fetch leaves the item as it was and never fails the build. + +`html2rss scrape URL --explain` reports `enriched`, `enrich_failed` and `enrich_skipped_cross_origin` counts when enrichment ran. + --- For detailed documentation on the Ruby API, see the [official YARD documentation](https://www.rubydoc.info/gems/html2rss). diff --git a/src/content/docs/ruby-gem/reference/language-support.mdx b/src/content/docs/ruby-gem/reference/language-support.mdx new file mode 100644 index 00000000..846c1d17 --- /dev/null +++ b/src/content/docs/ruby-gem/reference/language-support.mdx @@ -0,0 +1,86 @@ +--- +title: Language Support +description: "Which languages html2rss understands when it tells articles apart from page furniture, how the page language is chosen, and how to help improve a language." +--- + +import { Code } from "@astrojs/starlight/components"; + +html2rss recognizes words such as "read more", "sponsored", "advertisement", "related" and "comments" to tell real articles from page furniture. It reads these words in the page's own language. + +## Supported languages + +29 languages: + +| Code | Language | Code | Language | Code | Language | +| :--- | :------- | :--- | :--------- | :--- | :--------- | +| `ar` | Arabic | `hi` | Hindi | `ro` | Romanian | +| `cs` | Czech | `hu` | Hungarian | `ru` | Russian | +| `da` | Danish | `id` | Indonesian | `sv` | Swedish | +| `de` | German | `it` | Italian | `th` | Thai | +| `el` | Greek | `ja` | Japanese | `tr` | Turkish | +| `en` | English | `ko` | Korean | `uk` | Ukrainian | +| `es` | Spanish | `nl` | Dutch | `vi` | Vietnamese | +| `fa` | Persian | `no` | Norwegian | `zh` | Chinese | +| `fi` | Finnish | `pl` | Polish | | | +| `fr` | French | `pt` | Portuguese | | | +| `he` | Hebrew | | | | | + +Chinese covers Simplified and Traditional text in one list. A regional tag such as `de-AT` or `zh-Hant-TW` uses its main language. + +## How the page language is chosen + +html2rss takes the first of these: + +1. `channel.language` in your config +2. the `Content-Language` response header (upper or lower case; only the two-letter main tag counts) +3. the `lang` attribute of the page's root element + + + +Quote Norwegian in YAML: `language: "no"`. An unquoted `no` is read as `false` and fails validation. The tags `nb` (Bokmål) and `nn` (Nynorsk) use the Norwegian list. + +A word that is also a common word or name in some language, such as the Swedish share label "dela" (also a surname), counts only on a page in that language. If the language is blank or not in the list, every language's words apply. + +## Text and encodings + +- **Right-to-left text.** Invisible direction marks in Arabic, Hebrew and Persian text are ignored, so they no longer break title and sponsorship matching. +- **Chinese encodings.** Pages labeled `gbk` or `big5` decode the way browsers decode them. +- **Unknown encodings.** A page that declares a character set Ruby cannot convert is cleaned up instead of failing. + +## Help improve a language + +No native speaker has reviewed the word lists of these 18 languages: Arabic (`ar`), Chinese (`zh`), Czech (`cs`), Danish (`da`), Finnish (`fi`), Greek (`el`), Hebrew (`he`), Hindi (`hi`), Hungarian (`hu`), Indonesian (`id`), Korean (`ko`), Norwegian (`no`), Persian (`fa`), Romanian (`ro`), Thai (`th`), Turkish (`tr`), Ukrainian (`uk`) and Vietnamese (`vi`). If you read one of them, please check its file. You may spot a missing "read more", a wrong "sponsored", or a word that misfires. + +Each language is one small Ruby file: `lib/html2rss/vocabulary/.rb` in the [`html2rss` repository](https://github.com/html2rss/html2rss/tree/master/lib/html2rss/vocabulary). For example, `de.rb` is German. + +1. Open the file on GitHub. +2. Click the pencil (**Edit**) button. [GitHub explains how editing files works](https://docs.github.com/en/repositories/working-with-files/managing-files/editing-files). +3. Change the words and propose the change as a pull request. + +You do not need a local Ruby setup. + +### Add a new language + +Developers can add a language by following `CONTEXT.md` in the `html2rss` repository (section "Vocabulary"): + +1. Write `lib/html2rss/vocabulary/.rb` against the concept list of an existing language. +2. Add it to `Vocabulary::PAGE_ONLY`. New languages start there, so their words apply only on a page in that language. +3. Run the report against a folder of saved pages with a `manifest.tsv`: + + PAGES= + `} + lang="bash" +/> + +The report lists how feeds and link classification change, which words hit on your pages, and the memory cost. It decides nothing; a person reads the differences. diff --git a/src/content/docs/ruby-gem/reference/strategy.mdx b/src/content/docs/ruby-gem/reference/strategy.mdx index c816ad5b..68b978de 100644 --- a/src/content/docs/ruby-gem/reference/strategy.mdx +++ b/src/content/docs/ruby-gem/reference/strategy.mdx @@ -151,7 +151,7 @@ Use this split consistently: - `strategy`: selects `auto`, `default`, `botasaurus`, or `local_file` - `headers`: top-level headers shared by remote strategies (defaults to `html2rss/` User-Agent) - `request.max_redirects`: redirect limit for the request session (default: `5`) -- `request.max_requests`: total request budget for the whole feed build (default: `10`) +- `request.max_requests`: total request budget for the whole feed build. Hard ceiling: `10`; a higher value is capped. Without this key, html2rss reserves the slots your config needs (the page, extra pages, enabled `auto_source` follow-ups, entry probes, fallback steps), at least `1`, and never more than `10`. The CLI `--max-requests` flag and the Ruby `max_requests:` option set it explicitly. `Html2rss.scrape` without that option sets `4`. - `request.total_timeout_seconds`: maximum total wall-clock budget for the entire feed build - `request.local_file_path`: file path for `local_file` strategy - `request.botasaurus.*`: Botasaurus-only options