2016-08-13 20 views
7

Mam bardzo duży blok kodu w pliku .rst, który chciałbym podświetlić tylko małą częścią i pogrubić. Rozważmy następujący RST:Zaznacz część bloku kodu

wall of text. wall of text. wall of text.wall of text. wall of text. wall of text.wall of text. wall of text. wall of text. 
wall of text. wall of text. wall of text.wall of text. wall of text. wall of text.wall of text. wall of text. wall of text. 

**Example 1: Explain showing a table scan operation**:: 

    EXPLAIN FORMAT=JSON 
    SELECT * FROM Country WHERE continent='Asia' and population > 5000000; 
    { 
    "query_block": { 
     "select_id": 1, 
     "cost_info": { 
     "query_cost": "53.80"   # This query costs 53.80 cost units 
     }, 
     "table": { 
     "table_name": "Country", 
     "access_type": "ALL",   # ALL is a table scan 
     "rows_examined_per_scan": 239, # Accessing all 239 rows in the table 
     "rows_produced_per_join": 11, 
     "filtered": "4.76", 
     "cost_info": { 
     "read_cost": "51.52", 
     "eval_cost": "2.28", 
     "prefix_cost": "53.80", 
     "data_read_per_join": "2K" 
     }, 
     "used_columns": [ 
     "Code", 
     "Name", 
     "Continent", 
     "Region", 
     "SurfaceArea", 
     "IndepYear", 
     "Population", 
     "LifeExpectancy", 
     "GNP", 
     "GNPOld", 
     "LocalName", 
     "GovernmentForm", 
     "HeadOfState", 
     "Capital", 
     "Code2" 
     ], 
     "attached_condition": "((`world`.`Country`.`Continent` = 'Asia') and (`world`.`Country`.`Population` > 5000000))" 
     } 
    } 
    } 

Kiedy konwertuje do formatu html, to składnia pasemka domyślnie (dobre), ale także chcą podać kilka wierszy, które powinny być pogrubione (te z uwagi na nich, ale być może inne też.)

Zastanowiłem się nad dodaniem ciągów znaków na linii (.eg #@@), a następnie napisałem skrypt post-parsera, aby zmodyfikować wygenerowane pliki html. Czy istnieje lepszy sposób?

+0

Zerknąłeś na http://coderay.rubychan.de/ napisany dla rubinu, ale czy jest to coś, czego chcesz? (Będąc w stanie wprowadzić kod źródłowy i wyprowadzić go z formatowaniem html?) –

+0

Naprawdę lubię sfinksa. Właśnie miałem ten jeden problem z tym :) –

Odpowiedz

2

Dyrektywa code-block ma opcję emphasize-lines. Poniżej podświetlają linie z komentarzami w twoim kodzie.

**Example 1: Explain showing a table scan operation** 

.. code-block:: python 
    :emphasize-lines: 7, 11, 12 

    EXPLAIN FORMAT=JSON 
    SELECT * FROM Country WHERE continent='Asia' and population > 5000000; 
    { 
    "query_block": { 
     "select_id": 1, 
     "cost_info": { 
     "query_cost": "53.80"   # This query costs 53.80 cost units 
     }, 
     "table": { 
     "table_name": "Country", 
     "access_type": "ALL",   # ALL is a table scan 
     "rows_examined_per_scan": 239, # Accessing all 239 rows in the table 
     "rows_produced_per_join": 11, 
     "filtered": "4.76", 
     "cost_info": { 
     "read_cost": "51.52", 
     "eval_cost": "2.28", 
     "prefix_cost": "53.80", 
     "data_read_per_join": "2K" 
     }, 
     "used_columns": [ 
     "Code", 
     "Name", 
     "Continent", 
     "Region", 
     "SurfaceArea", 
     "IndepYear", 
     "Population", 
     "LifeExpectancy", 
     "GNP", 
     "GNPOld", 
     "LocalName", 
     "GovernmentForm", 
     "HeadOfState", 
     "Capital", 
     "Code2" 
     ], 
     "attached_condition": "((`world`.`Country`.`Continent` = 'Asia') and (`world`.`Country`.`Population` > 5000000))" 
     } 
    } 
    } 
+0

Działa idealnie. Dziękuję Ci! –

Powiązane problemy