From 7239f9b3fb3a459e78d7f3798fdef33da72e94bf Mon Sep 17 00:00:00 2001 From: Michael Frank <55284511+frank-at-adacore@users.noreply.github.com> Date: Tue, 11 Feb 2025 11:47:07 -0500 Subject: [PATCH 1/4] New way of dealing with URL's --- pandoc/beamer_filter.py | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/pandoc/beamer_filter.py b/pandoc/beamer_filter.py index 527947dee..4fea571b7 100755 --- a/pandoc/beamer_filter.py +++ b/pandoc/beamer_filter.py @@ -785,27 +785,30 @@ def format_menu(literal_text): """ "url" role -Pretty-print URL +Convert text to a LaTeX-based hyperlink. +If the text is in the format of `some text ` then we will use +a LaTeX "href" where "some text" is displayed and links to . +Otherwise, we will use "url" where the whole string is used +NOTE: For some reason, href's are not clickable in the PDF. For now, +we'll use a parenthesized link (which is clickable) rather than a +hidden one """ def format_url(literal_text): - # white text on box of color - url = latex_escape(literal_text) - - # shrink based on length of actual (not escaped) text - url_text = "" - if len(literal_text) <= 60: - url_text = "\\normalsize{" + url + "}" - elif len(literal_text) <= 67: - url_text = "\\small{" + url + "}" - elif len(literal_text) <= 71: - url_text = "\\footnotesize{" + url + "}" - elif len(literal_text) <= 80: - url_text = "\\scriptsize{" + url + "}" - else: - url_text = "\\tiny{" + url + "}" - return latex_inline("{" + latex_box(latex_color(url_text, "adacore1")) + "}") + + # href + # if literal_text.endswith(">"): + # first = literal_text.rfind("<") + # if first > 0: + # url = literal_text[first+1:len(literal_text)-1] + # text = literal_text[0:first-1].strip() + # if len(text) > 0: + # text = latex_escape(text) + # return latex_inline("\\href{" + url + "}{" + text + "}") + # + # anything else + return latex_inline("\\url{" + literal_text + "}") """ From 3efdf5e303835e805b4b9c4f51acfc8758ea77da Mon Sep 17 00:00:00 2001 From: Michael Frank <55284511+frank-at-adacore@users.noreply.github.com> Date: Tue, 11 Feb 2025 12:51:06 -0500 Subject: [PATCH 2/4] Better handling of rust cours URL's --- pandoc/beamer_filter.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pandoc/beamer_filter.py b/pandoc/beamer_filter.py index 4fea571b7..1c15c7d53 100755 --- a/pandoc/beamer_filter.py +++ b/pandoc/beamer_filter.py @@ -798,15 +798,15 @@ def format_menu(literal_text): def format_url(literal_text): # href - # if literal_text.endswith(">"): - # first = literal_text.rfind("<") - # if first > 0: - # url = literal_text[first+1:len(literal_text)-1] - # text = literal_text[0:first-1].strip() - # if len(text) > 0: - # text = latex_escape(text) - # return latex_inline("\\href{" + url + "}{" + text + "}") - # + if literal_text.endswith(">"): + first = literal_text.rfind("<") + if first > 0: + url = literal_text[first+1:len(literal_text)-1] + text = literal_text[0:first-1].strip() + if len(text) > 0: + text = latex_escape(text) + return latex_inline(text + " (\\url{" + url + "})") + # anything else return latex_inline("\\url{" + literal_text + "}") From eb0c7fa4289f81fa7a2e6ef22783a5291b5adf98 Mon Sep 17 00:00:00 2001 From: Michael Frank <55284511+frank-at-adacore@users.noreply.github.com> Date: Tue, 11 Feb 2025 14:53:34 -0500 Subject: [PATCH 3/4] Replace RST-style URL's with our own role --- .../020_hello_world/03_playground.rst | 2 +- .../030_types_and_values/01_hello_world.rst | 2 +- .../040_control_flow_basics/01_if.rst | 2 +- .../040_control_flow_basics/03_loops.rst | 2 +- .../04_break_continue.rst | 4 ++-- .../040_control_flow_basics/07_macros.rst | 2 +- .../040_control_flow_basics/08_exercise.rst | 2 +- .../02_tuple_structs.rst | 2 +- .../070_user_defined_types/03_enums.rst | 2 +- .../070_user_defined_types/04_aliases.rst | 2 +- .../070_user_defined_types/05_const.rst | 2 +- .../070_user_defined_types/06_static.rst | 4 ++-- .../04_let_control_flow.rst | 8 ++++---- .../090_methods_and_traits/01_methods.rst | 2 +- .../100_generics/03_generic_traits.rst | 4 ++-- .../100_generics/06_dyn_trait.rst | 2 +- .../100_generics/07_exercise.rst | 6 +++--- .../110_std_types/02_docs.rst | 12 ++++++------ .../110_std_types/03_option.rst | 2 +- .../110_std_types/05_string.rst | 8 ++++---- .../110_std_types/06_vec.rst | 4 ++-- .../110_std_types/07_hashmap.rst | 2 +- .../110_std_types/08_exercise.rst | 4 ++-- .../120_std_traits/02_operators.rst | 2 +- .../120_std_traits/03_from_and_into.rst | 8 ++++---- .../120_std_traits/05_read_and_write.rst | 6 +++--- .../120_std_traits/06_default.rst | 4 ++-- .../120_std_traits/07_closures.rst | 6 +++--- .../120_std_traits/08_exercise.rst | 2 +- .../130_memory_management/01_review.rst | 4 ++-- .../130_memory_management/04_move.rst | 2 +- .../130_memory_management/07_drop.rst | 2 +- .../140_smart_pointers/01_box.rst | 4 ++-- .../140_smart_pointers/02_rc.rst | 8 ++++---- .../140_smart_pointers/03_trait_objects.rst | 2 +- .../150_borrowing/01_shared.rst | 4 ++-- .../160_lifetimes/02_lifetime_elision.rst | 2 +- .../160_lifetimes/04_exercise.rst | 2 +- .../170_iterators/02_iterator.rst | 4 ++-- .../170_iterators/04_collect.rst | 6 +++--- .../170_iterators/05_intoiterator.rst | 2 +- .../170_iterators/06_exercise.rst | 2 +- .../180_modules/03_visibility.rst | 2 +- .../180_modules/04_encapsulation.rst | 2 +- .../190_testing/02_other.rst | 2 +- .../190_testing/03_lints.rst | 2 +- .../190_testing/04_exercise.rst | 2 +- .../200_error_handling/02_result.rst | 2 +- .../200_error_handling/06_thiserror.rst | 2 +- .../200_error_handling/07_anyhow.rst | 6 +++--- .../210_unsafe_rust/01_unsafe.rst | 4 ++-- .../210_unsafe_rust/02_dereferencing.rst | 2 +- .../210_unsafe_rust/04_unions.rst | 4 ++-- .../210_unsafe_rust/05_unsafe_functions.rst | 2 +- .../210_unsafe_rust/06_unsafe_traits.rst | 2 +- .../210_unsafe_rust/07_exercise.rst | 18 +++++++++--------- 56 files changed, 103 insertions(+), 103 deletions(-) diff --git a/courses/comprehensive_rust_training/020_hello_world/03_playground.rst b/courses/comprehensive_rust_training/020_hello_world/03_playground.rst index 4edb31cec..7bde35bba 100644 --- a/courses/comprehensive_rust_training/020_hello_world/03_playground.rst +++ b/courses/comprehensive_rust_training/020_hello_world/03_playground.rst @@ -6,7 +6,7 @@ Playground Playground ------------ -The `Rust Playground `__ provides an easy +The :url:`Rust Playground ` provides an easy way to run short Rust programs, and is the basis for the examples and exercises in this course. Try running the "hello-world" program it starts with. It comes with a few handy features: diff --git a/courses/comprehensive_rust_training/030_types_and_values/01_hello_world.rst b/courses/comprehensive_rust_training/030_types_and_values/01_hello_world.rst index f44de4689..3f6f41c2f 100644 --- a/courses/comprehensive_rust_training/030_types_and_values/01_hello_world.rst +++ b/courses/comprehensive_rust_training/030_types_and_values/01_hello_world.rst @@ -43,7 +43,7 @@ Key points: - Rust uses macros for situations where you want to have a variable number of arguments (no function - `overloading <../control-flow-basics/functions.md>`__). + :url:`overloading <../control-flow-basics/functions.md>`). - Macros being 'hygienic' means they don't accidentally capture identifiers from the scope they are used in. Rust macros are actually diff --git a/courses/comprehensive_rust_training/040_control_flow_basics/01_if.rst b/courses/comprehensive_rust_training/040_control_flow_basics/01_if.rst index 4422f9101..e9bcf6e6b 100644 --- a/courses/comprehensive_rust_training/040_control_flow_basics/01_if.rst +++ b/courses/comprehensive_rust_training/040_control_flow_basics/01_if.rst @@ -7,7 +7,7 @@ -------------------- You use -`if expressions `__ +:url:`if expressions ` exactly like ``if`` statements in other languages: .. code:: rust,editable diff --git a/courses/comprehensive_rust_training/040_control_flow_basics/03_loops.rst b/courses/comprehensive_rust_training/040_control_flow_basics/03_loops.rst index a8d7508d3..a5f475c36 100644 --- a/courses/comprehensive_rust_training/040_control_flow_basics/03_loops.rst +++ b/courses/comprehensive_rust_training/040_control_flow_basics/03_loops.rst @@ -14,7 +14,7 @@ There are three looping keywords in Rust: ``while``, ``loop``, and ----------- The -`while keyword `__ +:url:`while keyword ` works much like in other languages, executing the loop body as long as the condition is true. diff --git a/courses/comprehensive_rust_training/040_control_flow_basics/04_break_continue.rst b/courses/comprehensive_rust_training/040_control_flow_basics/04_break_continue.rst index 51fdfc7a5..db807310a 100644 --- a/courses/comprehensive_rust_training/040_control_flow_basics/04_break_continue.rst +++ b/courses/comprehensive_rust_training/040_control_flow_basics/04_break_continue.rst @@ -7,10 +7,10 @@ ---------------------------- If you want to immediately start the next iteration use -`continue `__. +:url:`continue `. If you want to exit any kind of loop early, use -`break `__. +:url:`break `. With ``loop``, this can take an optional expression that becomes the value of the ``loop`` expression. diff --git a/courses/comprehensive_rust_training/040_control_flow_basics/07_macros.rst b/courses/comprehensive_rust_training/040_control_flow_basics/07_macros.rst index eccc7b051..91d6de2bd 100644 --- a/courses/comprehensive_rust_training/040_control_flow_basics/07_macros.rst +++ b/courses/comprehensive_rust_training/040_control_flow_basics/07_macros.rst @@ -12,7 +12,7 @@ end. The Rust standard library includes an assortment of useful macros. - ``println!(format, ..)`` prints a line to standard output, applying formatting described in - `std::fmt `__. + :url:`std::fmt `. - ``format!(format, ..)`` works just like ``println!`` but returns the result as a string. - ``dbg!(expression)`` logs the value of the expression and returns it. diff --git a/courses/comprehensive_rust_training/040_control_flow_basics/08_exercise.rst b/courses/comprehensive_rust_training/040_control_flow_basics/08_exercise.rst index c2a3f5993..6583dcfa2 100644 --- a/courses/comprehensive_rust_training/040_control_flow_basics/08_exercise.rst +++ b/courses/comprehensive_rust_training/040_control_flow_basics/08_exercise.rst @@ -7,7 +7,7 @@ Exercise: Collatz Sequence ---------------------------- The -`Collatz Sequence `__ is +:url:`Collatz Sequence ` is defined as follows, for an arbitrary n1 greater than zero: - If *ni* is 1, then the sequence terminates at *ni*. diff --git a/courses/comprehensive_rust_training/070_user_defined_types/02_tuple_structs.rst b/courses/comprehensive_rust_training/070_user_defined_types/02_tuple_structs.rst index a9b91c994..b5792b3ee 100644 --- a/courses/comprehensive_rust_training/070_user_defined_types/02_tuple_structs.rst +++ b/courses/comprehensive_rust_training/070_user_defined_types/02_tuple_structs.rst @@ -66,7 +66,7 @@ Details - Operator overloading is discussed on Day 3 (generics). - The example is a subtle reference to the - `Mars Climate Orbiter `__ + :url:`Mars Climate Orbiter ` failure. .. raw:: html diff --git a/courses/comprehensive_rust_training/070_user_defined_types/03_enums.rst b/courses/comprehensive_rust_training/070_user_defined_types/03_enums.rst index 721128ec9..3eb244d25 100644 --- a/courses/comprehensive_rust_training/070_user_defined_types/03_enums.rst +++ b/courses/comprehensive_rust_training/070_user_defined_types/03_enums.rst @@ -93,7 +93,7 @@ Rust has several optimizations it can employ to make enums take up less space. - Null pointer optimization: For - `some types `__, Rust + :url:`some types `, Rust guarantees that ``size_of::()`` equals ``size_of::>()``. Example code if you want to show how the bitwise representation *may* diff --git a/courses/comprehensive_rust_training/070_user_defined_types/04_aliases.rst b/courses/comprehensive_rust_training/070_user_defined_types/04_aliases.rst index 75752ebca..cb6b191ba 100644 --- a/courses/comprehensive_rust_training/070_user_defined_types/04_aliases.rst +++ b/courses/comprehensive_rust_training/070_user_defined_types/04_aliases.rst @@ -29,7 +29,7 @@ interchangeably. Details --------- -- A `newtype `__ is often a better alternative +- A :url:`newtype ` is often a better alternative since it creates a distinct type. Prefer ``struct InventoryCount(usize)`` to ``type InventoryCount = usize``. diff --git a/courses/comprehensive_rust_training/070_user_defined_types/05_const.rst b/courses/comprehensive_rust_training/070_user_defined_types/05_const.rst index 9fcc4b4a8..73b78ca61 100644 --- a/courses/comprehensive_rust_training/070_user_defined_types/05_const.rst +++ b/courses/comprehensive_rust_training/070_user_defined_types/05_const.rst @@ -40,7 +40,7 @@ wherever they are used: } According to the -`Rust RFC Book `__ +:url:`Rust RFC Book ` these are inlined upon use. Only functions marked ``const`` can be called at compile time to diff --git a/courses/comprehensive_rust_training/070_user_defined_types/06_static.rst b/courses/comprehensive_rust_training/070_user_defined_types/06_static.rst index 510f0c1b0..e8e09acfc 100644 --- a/courses/comprehensive_rust_training/070_user_defined_types/06_static.rst +++ b/courses/comprehensive_rust_training/070_user_defined_types/06_static.rst @@ -18,7 +18,7 @@ and therefore will not move: } As noted in the -`Rust RFC Book `__, +:url:`Rust RFC Book `, these are not inlined upon use and have an actual associated memory location. This is useful for unsafe and embedded code, and the variable lives through the entirety of the program execution. When a @@ -45,7 +45,7 @@ More to Explore Because ``static`` variables are accessible from any thread, they must be ``Sync``. Interior mutability is possible through a -`Mutex `__, +:url:`Mutex `, atomic or similar. It is common to use ``OnceLock`` in a static as a way to support diff --git a/courses/comprehensive_rust_training/080_pattern_matching/04_let_control_flow.rst b/courses/comprehensive_rust_training/080_pattern_matching/04_let_control_flow.rst index 7b9413c2b..2907e47a1 100644 --- a/courses/comprehensive_rust_training/080_pattern_matching/04_let_control_flow.rst +++ b/courses/comprehensive_rust_training/080_pattern_matching/04_let_control_flow.rst @@ -22,7 +22,7 @@ languages. They are used for pattern matching: ------------------------ The -`if let expression `__ +:url:`if let expression ` lets you execute different code depending on whether a value matches a pattern: @@ -52,7 +52,7 @@ pattern: For the common case of matching a pattern and returning from the function, use -`let else `__. +:url:`let else `. The "else" case must diverge (``return``, ``break``, or panic - anything but falling off the end of the block). @@ -80,7 +80,7 @@ but falling off the end of the block). } Like with ``if let``, there is a -`while let `__ +:url:`while let ` variant which repeatedly tests a value against a pattern: .. raw:: html @@ -98,7 +98,7 @@ variant which repeatedly tests a value against a pattern: } Here -`String::pop `__ +:url:`String::pop ` returns ``Some(c)`` until the string is empty, after which it will return ``None``. The ``while let`` lets us keep iterating through all items. diff --git a/courses/comprehensive_rust_training/090_methods_and_traits/01_methods.rst b/courses/comprehensive_rust_training/090_methods_and_traits/01_methods.rst index bcec67c18..38a9599ea 100644 --- a/courses/comprehensive_rust_training/090_methods_and_traits/01_methods.rst +++ b/courses/comprehensive_rust_training/090_methods_and_traits/01_methods.rst @@ -99,7 +99,7 @@ Key Points: - This might be a good time to demonstrate how the ``&self`` differs from ``self`` by trying to run ``finish`` twice. - Beyond variants on ``self``, there are also - `special wrapper types `__ + :url:`special wrapper types ` allowed to be receiver types, such as ``Box``. .. raw:: html diff --git a/courses/comprehensive_rust_training/100_generics/03_generic_traits.rst b/courses/comprehensive_rust_training/100_generics/03_generic_traits.rst index fb70d1bd7..2de9eb696 100644 --- a/courses/comprehensive_rust_training/100_generics/03_generic_traits.rst +++ b/courses/comprehensive_rust_training/100_generics/03_generic_traits.rst @@ -39,7 +39,7 @@ Details --------- - The ``From`` trait will be covered later in the course, but its - `definition in the std docs `__ + :url:`definition in the std docs ` is simple. - Implementations of the trait do not need to cover all possible type @@ -54,7 +54,7 @@ Details match for any type T. Unlike some other languages, Rust has no heuristic for choosing the "most specific" match. There is work on adding this support, called - `specialization `__. + :url:`specialization `. .. raw:: html diff --git a/courses/comprehensive_rust_training/100_generics/06_dyn_trait.rst b/courses/comprehensive_rust_training/100_generics/06_dyn_trait.rst index c64955363..661ae0fa9 100644 --- a/courses/comprehensive_rust_training/100_generics/06_dyn_trait.rst +++ b/courses/comprehensive_rust_training/100_generics/06_dyn_trait.rst @@ -70,7 +70,7 @@ Details implementation to use. - When using ``dyn Trait``, it instead uses dynamic dispatch through a - `virtual method table `__ + :url:`virtual method table ` (vtable). This means that there's a single version of ``fn dynamic`` that is used regardless of what type of ``Pet`` is passed in. diff --git a/courses/comprehensive_rust_training/100_generics/07_exercise.rst b/courses/comprehensive_rust_training/100_generics/07_exercise.rst index c9f8d90f2..2ce073e67 100644 --- a/courses/comprehensive_rust_training/100_generics/07_exercise.rst +++ b/courses/comprehensive_rust_training/100_generics/07_exercise.rst @@ -8,7 +8,7 @@ Exercise: Generic ``min`` In this short exercise, you will implement a generic ``min`` function that determines the minimum of two values, using the -`Ord `__ +:url:`Ord ` trait. .. code:: rust,compile_fail @@ -26,9 +26,9 @@ Details --------- - Show students the - `Ord `__ + :url:`Ord ` trait and - `Ordering `__ + :url:`Ordering ` enum. .. raw:: html diff --git a/courses/comprehensive_rust_training/110_std_types/02_docs.rst b/courses/comprehensive_rust_training/110_std_types/02_docs.rst index 2faa8d586..aeca4d1ab 100644 --- a/courses/comprehensive_rust_training/110_std_types/02_docs.rst +++ b/courses/comprehensive_rust_training/110_std_types/02_docs.rst @@ -9,13 +9,13 @@ Documentation Rust comes with extensive documentation. For example: - All of the details about - `loops `__. + :url:`loops `. - Primitive types like - `u8 `__. + :url:`u8 `. - Standard library types like - `Option `__ + :url:`Option ` or - `BinaryHeap `__. + :url:`BinaryHeap `. Use ``rustup doc --std`` or https://std.rs to view the documentation. @@ -34,8 +34,8 @@ In fact, you can document your own code: } The contents are treated as Markdown. All published Rust library crates -are automatically documented at `docs.rs `__ using -the `rustdoc `__ +are automatically documented at :url:`docs.rs ` using +the :url:`rustdoc ` tool. It is idiomatic to document all public items in an API using this pattern. diff --git a/courses/comprehensive_rust_training/110_std_types/03_option.rst b/courses/comprehensive_rust_training/110_std_types/03_option.rst index 704fb1561..bbf56b08c 100644 --- a/courses/comprehensive_rust_training/110_std_types/03_option.rst +++ b/courses/comprehensive_rust_training/110_std_types/03_option.rst @@ -8,7 +8,7 @@ Option We have already seen some use of ``Option``. It stores either a value of type ``T`` or nothing. For example, -`String::find `__ +:url:`String::find ` returns an ``Option``. .. code:: rust,editable,should_panic diff --git a/courses/comprehensive_rust_training/110_std_types/05_string.rst b/courses/comprehensive_rust_training/110_std_types/05_string.rst index 1a4c1f364..a64dda94b 100644 --- a/courses/comprehensive_rust_training/110_std_types/05_string.rst +++ b/courses/comprehensive_rust_training/110_std_types/05_string.rst @@ -6,7 +6,7 @@ String String -------- -`String `__ +:url:`String ` is a growable UTF-8 encoded string: .. code:: rust,editable @@ -26,7 +26,7 @@ is a growable UTF-8 encoded string: } ``String`` implements -`Deref `__, +:url:`Deref `, which means that you can call all ``str`` methods on a ``String``. .. raw:: html @@ -43,7 +43,7 @@ Details - ``String::chars`` returns an iterator over the actual characters. Note that a ``char`` can be different from what a human will consider a "character" due to - `grapheme clusters `__. + :url:`grapheme clusters `. - When people refer to strings they could either be talking about ``&str`` or ``String``. - When a type implements ``Deref``, the compiler will let @@ -67,7 +67,7 @@ Details character boundaries or not. - Many types can be converted to a string with the - `to_string `__ + :url:`to_string ` method. This trait is automatically implemented for all types that implement ``Display``, so anything that can be formatted can also be converted to a string. diff --git a/courses/comprehensive_rust_training/110_std_types/06_vec.rst b/courses/comprehensive_rust_training/110_std_types/06_vec.rst index d72b8726c..5bcc46dc5 100644 --- a/courses/comprehensive_rust_training/110_std_types/06_vec.rst +++ b/courses/comprehensive_rust_training/110_std_types/06_vec.rst @@ -6,7 +6,7 @@ ``Vec`` --------- -`Vec `__ is the +:url:`Vec ` is the standard resizable heap-allocated buffer: .. code:: rust,editable @@ -34,7 +34,7 @@ standard resizable heap-allocated buffer: } ``Vec`` implements -`Deref `__, +:url:`Deref `, which means that you can call slice methods on a ``Vec``. .. raw:: html diff --git a/courses/comprehensive_rust_training/110_std_types/07_hashmap.rst b/courses/comprehensive_rust_training/110_std_types/07_hashmap.rst index d3e94dbae..c933bd828 100644 --- a/courses/comprehensive_rust_training/110_std_types/07_hashmap.rst +++ b/courses/comprehensive_rust_training/110_std_types/07_hashmap.rst @@ -68,7 +68,7 @@ Details macro. - Although, since Rust 1.56, HashMap implements - `From<[(K, V); N]> `__, + :url:`From<[(K, V); N]> `, which allows us to easily initialize a hash map from a literal array: diff --git a/courses/comprehensive_rust_training/110_std_types/08_exercise.rst b/courses/comprehensive_rust_training/110_std_types/08_exercise.rst index 5b7d91a2d..a383f7b92 100644 --- a/courses/comprehensive_rust_training/110_std_types/08_exercise.rst +++ b/courses/comprehensive_rust_training/110_std_types/08_exercise.rst @@ -8,7 +8,7 @@ Exercise: Counter In this exercise you will take a very simple data structure and make it generic. It uses a -`std::collections::HashMap `__ +:url:`std::collections::HashMap ` to keep track of which values have been seen and how many times each one has appeared. @@ -17,7 +17,7 @@ The initial version of ``Counter`` is hard coded to only work for value being tracked, that way ``Counter`` can track any type of value. If you finish early, try using the -`entry `__ +:url:`entry ` method to halve the number of hash lookups required to implement the ``count`` method. diff --git a/courses/comprehensive_rust_training/120_std_traits/02_operators.rst b/courses/comprehensive_rust_training/120_std_traits/02_operators.rst index 2e9a7679e..aa0e63cf8 100644 --- a/courses/comprehensive_rust_training/120_std_traits/02_operators.rst +++ b/courses/comprehensive_rust_training/120_std_traits/02_operators.rst @@ -7,7 +7,7 @@ Operators ----------- Operator overloading is implemented via traits in -`std::ops `__: +:url:`std::ops `: .. code:: rust,editable diff --git a/courses/comprehensive_rust_training/120_std_traits/03_from_and_into.rst b/courses/comprehensive_rust_training/120_std_traits/03_from_and_into.rst index deb1ff902..0ac85bf70 100644 --- a/courses/comprehensive_rust_training/120_std_traits/03_from_and_into.rst +++ b/courses/comprehensive_rust_training/120_std_traits/03_from_and_into.rst @@ -7,8 +7,8 @@ ----------------------- Types implement -`From `__ and -`Into `__ to +:url:`From ` and +:url:`Into ` to facilitate type conversions. Unlike ``as``, these traits correspond to lossless, infallible conversions. @@ -22,9 +22,9 @@ lossless, infallible conversions. println!("{s}, {addr}, {one}, {bigger}"); } -`Into `__ is +:url:`Into ` is automatically implemented when -`From `__ is +:url:`From ` is implemented: .. code:: rust,editable diff --git a/courses/comprehensive_rust_training/120_std_traits/05_read_and_write.rst b/courses/comprehensive_rust_training/120_std_traits/05_read_and_write.rst index 9c93c7b08..1a4b58504 100644 --- a/courses/comprehensive_rust_training/120_std_traits/05_read_and_write.rst +++ b/courses/comprehensive_rust_training/120_std_traits/05_read_and_write.rst @@ -6,9 +6,9 @@ ``Read`` and ``Write`` ------------------------ -Using `Read `__ +Using :url:`Read ` and -`BufRead `__, +:url:`BufRead `, you can abstract over ``u8`` sources: .. code:: rust,editable @@ -30,7 +30,7 @@ you can abstract over ``u8`` sources: } Similarly, -`Write `__ lets +:url:`Write ` lets you abstract over ``u8`` sinks: .. code:: rust,editable diff --git a/courses/comprehensive_rust_training/120_std_traits/06_default.rst b/courses/comprehensive_rust_training/120_std_traits/06_default.rst index 32cd57eee..01c23f312 100644 --- a/courses/comprehensive_rust_training/120_std_traits/06_default.rst +++ b/courses/comprehensive_rust_training/120_std_traits/06_default.rst @@ -6,7 +6,7 @@ The ``Default`` Trait The ``Default`` Trait ----------------------- -`Default `__ +:url:`Default ` trait produces a default value for a type. .. code:: rust,editable @@ -58,7 +58,7 @@ Details - The Rust standard library is aware that types can implement ``Default`` and provides convenience methods that use it. - The ``..`` syntax is called - `struct update syntax `__. + :url:`struct update syntax `. .. raw:: html diff --git a/courses/comprehensive_rust_training/120_std_traits/07_closures.rst b/courses/comprehensive_rust_training/120_std_traits/07_closures.rst index 1bb5bfd76..0f423cd07 100644 --- a/courses/comprehensive_rust_training/120_std_traits/07_closures.rst +++ b/courses/comprehensive_rust_training/120_std_traits/07_closures.rst @@ -8,9 +8,9 @@ Closures Closures or lambda expressions have types which cannot be named. However, they implement special -`Fn `__, -`FnMut `__, and -`FnOnce `__ +:url:`Fn `, +:url:`FnMut `, and +:url:`FnOnce ` traits: .. code:: rust,editable diff --git a/courses/comprehensive_rust_training/120_std_traits/08_exercise.rst b/courses/comprehensive_rust_training/120_std_traits/08_exercise.rst index 05cd87433..8179c86c9 100644 --- a/courses/comprehensive_rust_training/120_std_traits/08_exercise.rst +++ b/courses/comprehensive_rust_training/120_std_traits/08_exercise.rst @@ -7,7 +7,7 @@ Exercise: ROT13 ----------------- In this example, you will implement the classic -`"ROT13" cipher `__. Copy this code to the +:url:`"ROT13" cipher `. Copy this code to the playground, and implement the missing bits. Only rotate ASCII alphabetic characters, to ensure the result is still valid UTF-8. diff --git a/courses/comprehensive_rust_training/130_memory_management/01_review.rst b/courses/comprehensive_rust_training/130_memory_management/01_review.rst index 16e775ea7..c38397a64 100644 --- a/courses/comprehensive_rust_training/130_memory_management/01_review.rst +++ b/courses/comprehensive_rust_training/130_memory_management/01_review.rst @@ -60,9 +60,9 @@ Details - If students ask about it, you can mention that the underlying memory is heap allocated using the - `System Allocator `__ + :url:`System Allocator ` and custom allocators can be implemented using the - `Allocator API `__ + :url:`Allocator API ` ----------------- More to Explore diff --git a/courses/comprehensive_rust_training/130_memory_management/04_move.rst b/courses/comprehensive_rust_training/130_memory_management/04_move.rst index 8cdac3d43..04f9a8707 100644 --- a/courses/comprehensive_rust_training/130_memory_management/04_move.rst +++ b/courses/comprehensive_rust_training/130_memory_management/04_move.rst @@ -181,7 +181,7 @@ Key points: a double-free when either string goes out of scope. - C++ also has - `std::move `__, + :url:`std::move `, which is used to indicate when a value may be moved from. If the example had been ``s2 = std::move(s1)``, no heap allocation would take place. After the move, ``s1`` would be in a valid but diff --git a/courses/comprehensive_rust_training/130_memory_management/07_drop.rst b/courses/comprehensive_rust_training/130_memory_management/07_drop.rst index e5d218a6e..337bb58b1 100644 --- a/courses/comprehensive_rust_training/130_memory_management/07_drop.rst +++ b/courses/comprehensive_rust_training/130_memory_management/07_drop.rst @@ -7,7 +7,7 @@ The ``Drop`` Trait -------------------- Values which implement -`Drop `__ can +:url:`Drop ` can specify code to run when they go out of scope: .. code:: rust,editable diff --git a/courses/comprehensive_rust_training/140_smart_pointers/01_box.rst b/courses/comprehensive_rust_training/140_smart_pointers/01_box.rst index 0da5865ff..3f7842256 100644 --- a/courses/comprehensive_rust_training/140_smart_pointers/01_box.rst +++ b/courses/comprehensive_rust_training/140_smart_pointers/01_box.rst @@ -6,7 +6,7 @@ ``Box`` ------------ -`Box `__ is an +:url:`Box ` is an owned pointer to data on the heap: .. code:: rust,editable @@ -30,7 +30,7 @@ owned pointer to data on the heap: `- - - - - - -' `- - - - - - -' ``Box`` implements ``Deref``, which means that you can -`call methods from T directly on a Box `__. +:url:`call methods from T directly on a Box `. Recursive data types or data types with dynamic sizes cannot be stored inline without a pointer indirection. ``Box`` accomplishes that diff --git a/courses/comprehensive_rust_training/140_smart_pointers/02_rc.rst b/courses/comprehensive_rust_training/140_smart_pointers/02_rc.rst index 509db1b42..a31d911e5 100644 --- a/courses/comprehensive_rust_training/140_smart_pointers/02_rc.rst +++ b/courses/comprehensive_rust_training/140_smart_pointers/02_rc.rst @@ -6,7 +6,7 @@ ``Rc`` -------- -`Rc `__ is a +:url:`Rc ` is a reference-counted shared pointer. Use this when you need to refer to the same data from multiple places: @@ -22,11 +22,11 @@ same data from multiple places: println!("b: {b}"); } -- See ```Arc`` <../concurrency/shared-state/arc.md>`__ and - `Mutex `__ +- See ```Arc`:url:` <../concurrency/shared-state/arc.md>` and + :url:`Mutex ` if you are in a multi-threaded context. - You can *downgrade* a shared pointer into a - `Weak `__ + :url:`Weak ` pointer to create cycles that will get dropped. .. raw:: html diff --git a/courses/comprehensive_rust_training/140_smart_pointers/03_trait_objects.rst b/courses/comprehensive_rust_training/140_smart_pointers/03_trait_objects.rst index 1a64da882..7eb764bbe 100644 --- a/courses/comprehensive_rust_training/140_smart_pointers/03_trait_objects.rst +++ b/courses/comprehensive_rust_training/140_smart_pointers/03_trait_objects.rst @@ -98,7 +98,7 @@ Details - A fat pointer is a double-width pointer. It has two components: a pointer to the actual object and a pointer to the - `virtual method table `__ + :url:`virtual method table ` (vtable) for the ``Pet`` implementation of that particular object. - The data for the ``Dog`` named Fido is the ``name`` and ``age`` fields. The ``Cat`` has a ``lives`` field. diff --git a/courses/comprehensive_rust_training/150_borrowing/01_shared.rst b/courses/comprehensive_rust_training/150_borrowing/01_shared.rst index b66dcef5d..e68894fa4 100644 --- a/courses/comprehensive_rust_training/150_borrowing/01_shared.rst +++ b/courses/comprehensive_rust_training/150_borrowing/01_shared.rst @@ -55,8 +55,8 @@ Notes on stack returns and inlining: compiler can eliminate the copy operation, by inlining the call to add into main. Change the above code to print stack addresses and run it on the - `Playground `__ - or look at the assembly in `Godbolt `__. + :url:`Playground ` + or look at the assembly in :url:`Godbolt `. In the "DEBUG" optimization level, the addresses should change, while they stay the same when changing to the "RELEASE" setting: diff --git a/courses/comprehensive_rust_training/160_lifetimes/02_lifetime_elision.rst b/courses/comprehensive_rust_training/160_lifetimes/02_lifetime_elision.rst index 2f729b005..83328267f 100644 --- a/courses/comprehensive_rust_training/160_lifetimes/02_lifetime_elision.rst +++ b/courses/comprehensive_rust_training/160_lifetimes/02_lifetime_elision.rst @@ -8,7 +8,7 @@ Lifetimes in Function Calls Lifetimes for function arguments and return values must be fully specified, but Rust allows lifetimes to be elided in most cases with -`a few simple rules `__. This +:url:`a few simple rules `. This is not inference - it is just a syntactic shorthand. - Each argument which does not have a lifetime annotation is given one. diff --git a/courses/comprehensive_rust_training/160_lifetimes/04_exercise.rst b/courses/comprehensive_rust_training/160_lifetimes/04_exercise.rst index 1c82dd6cc..db4e1792f 100644 --- a/courses/comprehensive_rust_training/160_lifetimes/04_exercise.rst +++ b/courses/comprehensive_rust_training/160_lifetimes/04_exercise.rst @@ -7,7 +7,7 @@ Exercise: Protobuf Parsing ---------------------------- In this exercise, you will build a parser for the -`protobuf binary encoding `__. Don't +:url:`protobuf binary encoding `. Don't worry, it's simpler than it seems! This illustrates a common parsing pattern, passing slices of data. The underlying data itself is never copied. diff --git a/courses/comprehensive_rust_training/170_iterators/02_iterator.rst b/courses/comprehensive_rust_training/170_iterators/02_iterator.rst index ef9dc7db5..ee812891b 100644 --- a/courses/comprehensive_rust_training/170_iterators/02_iterator.rst +++ b/courses/comprehensive_rust_training/170_iterators/02_iterator.rst @@ -7,7 +7,7 @@ -------------------- The -`Iterator `__ +:url:`Iterator ` trait defines how an object can be used to produce a sequence of values. For example, if we wanted to create an iterator that can produce the elements of a slice it might look something like this: @@ -63,7 +63,7 @@ More to Explore ----------------- - The "real" version of ``SliceIter`` is the - `slice::Iter `__ + :url:`slice::Iter ` type in the standard library, however the real version uses pointers under the hood instead of an index in order to eliminate bounds checks. diff --git a/courses/comprehensive_rust_training/170_iterators/04_collect.rst b/courses/comprehensive_rust_training/170_iterators/04_collect.rst index 04c73ddd6..b0463ce1d 100644 --- a/courses/comprehensive_rust_training/170_iterators/04_collect.rst +++ b/courses/comprehensive_rust_training/170_iterators/04_collect.rst @@ -7,9 +7,9 @@ ------------- The -`collect `__ +:url:`collect ` method lets you build a collection from an -`Iterator `__. +:url:`Iterator `. .. code:: rust,editable @@ -46,7 +46,7 @@ More to Explore ----------------- - If students are curious about how this works, you can bring up the - `FromIterator `__ + :url:`FromIterator ` trait, which defines how each type of collection gets built from an iterator. - In addition to the basic implementations of ``FromIterator`` for diff --git a/courses/comprehensive_rust_training/170_iterators/05_intoiterator.rst b/courses/comprehensive_rust_training/170_iterators/05_intoiterator.rst index 8816d53bd..c009c0143 100644 --- a/courses/comprehensive_rust_training/170_iterators/05_intoiterator.rst +++ b/courses/comprehensive_rust_training/170_iterators/05_intoiterator.rst @@ -8,7 +8,7 @@ The ``Iterator`` trait tells you how to *iterate* once you have created an iterator. The related trait -`IntoIterator `__ +:url:`IntoIterator ` defines how to create an iterator for a type. It is used automatically by the ``for`` loop. diff --git a/courses/comprehensive_rust_training/170_iterators/06_exercise.rst b/courses/comprehensive_rust_training/170_iterators/06_exercise.rst index 4060d4b2d..cb21ac074 100644 --- a/courses/comprehensive_rust_training/170_iterators/06_exercise.rst +++ b/courses/comprehensive_rust_training/170_iterators/06_exercise.rst @@ -8,7 +8,7 @@ Exercise: Iterator Method Chaining In this exercise, you will need to find and use some of the provided methods in the -`Iterator `__ +:url:`Iterator ` trait to implement a complex calculation. Copy the following code to https://play.rust-lang.org/ and make the diff --git a/courses/comprehensive_rust_training/180_modules/03_visibility.rst b/courses/comprehensive_rust_training/180_modules/03_visibility.rst index c5e40b8cb..326167c49 100644 --- a/courses/comprehensive_rust_training/180_modules/03_visibility.rst +++ b/courses/comprehensive_rust_training/180_modules/03_visibility.rst @@ -52,7 +52,7 @@ Additionally, there are advanced ``pub(...)`` specifiers to restrict the scope of public visibility. - See the - `Rust Reference `__. + :url:`Rust Reference `. - Configuring ``pub(crate)`` visibility is a common pattern. - Less commonly, you can give visibility to a specific path. - In any case, visibility must be granted to an ancestor module (and diff --git a/courses/comprehensive_rust_training/180_modules/04_encapsulation.rst b/courses/comprehensive_rust_training/180_modules/04_encapsulation.rst index 0b2dd2861..4152ab31f 100644 --- a/courses/comprehensive_rust_training/180_modules/04_encapsulation.rst +++ b/courses/comprehensive_rust_training/180_modules/04_encapsulation.rst @@ -84,7 +84,7 @@ More to Explore - Module privacy still applies when there are ``impl`` blocks in other modules - `(example in the playground) `__. + :url:`(example in the playground) `. .. raw:: html diff --git a/courses/comprehensive_rust_training/190_testing/02_other.rst b/courses/comprehensive_rust_training/190_testing/02_other.rst index 146224bd5..98b19998e 100644 --- a/courses/comprehensive_rust_training/190_testing/02_other.rst +++ b/courses/comprehensive_rust_training/190_testing/02_other.rst @@ -50,4 +50,4 @@ Rust has built-in support for documentation tests: - Adding ``#`` in the code will hide it from the docs, but will still compile/run it. - Test the above code on the - `Rust Playground `__. + :url:`Rust Playground `. diff --git a/courses/comprehensive_rust_training/190_testing/03_lints.rst b/courses/comprehensive_rust_training/190_testing/03_lints.rst index 510dca137..9c013adc8 100644 --- a/courses/comprehensive_rust_training/190_testing/03_lints.rst +++ b/courses/comprehensive_rust_training/190_testing/03_lints.rst @@ -7,7 +7,7 @@ Compiler Lints and Clippy --------------------------- The Rust compiler produces fantastic error messages, as well as helpful -built-in lints. `Clippy `__ provides +built-in lints. :url:`Clippy ` provides even more lints, organized into groups that can be enabled per-project. .. code:: rust,editable,should_panic,warnunused diff --git a/courses/comprehensive_rust_training/190_testing/04_exercise.rst b/courses/comprehensive_rust_training/190_testing/04_exercise.rst index 633f84215..ddf5e2b28 100644 --- a/courses/comprehensive_rust_training/190_testing/04_exercise.rst +++ b/courses/comprehensive_rust_training/190_testing/04_exercise.rst @@ -6,7 +6,7 @@ Exercise: Luhn Algorithm Exercise: Luhn Algorithm -------------------------- -The `Luhn algorithm `__ is +The :url:`Luhn algorithm ` is used to validate credit card numbers. The algorithm takes a string as input and does the following to validate the credit card number: diff --git a/courses/comprehensive_rust_training/200_error_handling/02_result.rst b/courses/comprehensive_rust_training/200_error_handling/02_result.rst index 8eb6f64ea..bc3aa5022 100644 --- a/courses/comprehensive_rust_training/200_error_handling/02_result.rst +++ b/courses/comprehensive_rust_training/200_error_handling/02_result.rst @@ -7,7 +7,7 @@ ------------ Our primary mechanism for error handling in Rust is the -`Result `__ +:url:`Result ` enum, which we briefly saw when discussing standard library types. .. code:: rust,editable diff --git a/courses/comprehensive_rust_training/200_error_handling/06_thiserror.rst b/courses/comprehensive_rust_training/200_error_handling/06_thiserror.rst index bb84afdcf..804ee042f 100644 --- a/courses/comprehensive_rust_training/200_error_handling/06_thiserror.rst +++ b/courses/comprehensive_rust_training/200_error_handling/06_thiserror.rst @@ -6,7 +6,7 @@ ``thiserror`` --------------- -The `thiserror `__ crate provides macros +The :url:`thiserror ` crate provides macros to help avoid boilerplate when defining error types. It provides derive macros that assist in implementing ``From``, ``Display``, and the ``Error`` trait. diff --git a/courses/comprehensive_rust_training/200_error_handling/07_anyhow.rst b/courses/comprehensive_rust_training/200_error_handling/07_anyhow.rst index c920169c8..8ae8a4613 100644 --- a/courses/comprehensive_rust_training/200_error_handling/07_anyhow.rst +++ b/courses/comprehensive_rust_training/200_error_handling/07_anyhow.rst @@ -6,13 +6,13 @@ ``anyhow`` ------------ -The `anyhow `__ crate provides a rich error +The :url:`anyhow ` crate provides a rich error type with support for carrying additional contextual information, which can be used to provide a semantic trace of what the program was doing leading up to the error. This can be combined with the convenience macros from -`thiserror `__ to avoid writing out +:url:`thiserror ` to avoid writing out trait impls explicitly for custom error types. .. code:: rust,editable,compile_fail @@ -77,7 +77,7 @@ More to Explore - ``anyhow::Error`` has support for downcasting, much like ``std::any::Any``; the specific error type stored inside can be extracted for examination if desired with - `Error::downcast `__. + :url:`Error::downcast `. .. raw:: html diff --git a/courses/comprehensive_rust_training/210_unsafe_rust/01_unsafe.rst b/courses/comprehensive_rust_training/210_unsafe_rust/01_unsafe.rst index 3dec2e85f..93800cc8b 100644 --- a/courses/comprehensive_rust_training/210_unsafe_rust/01_unsafe.rst +++ b/courses/comprehensive_rust_training/210_unsafe_rust/01_unsafe.rst @@ -28,8 +28,8 @@ Unsafe Rust gives you access to five new capabilities: We will briefly cover unsafe capabilities next. For full details, please see -`Chapter 19.1 in the Rust Book `__ and -the `Rustonomicon `__. +:url:`Chapter 19.1 in the Rust Book ` and +the :url:`Rustonomicon `. .. raw:: html diff --git a/courses/comprehensive_rust_training/210_unsafe_rust/02_dereferencing.rst b/courses/comprehensive_rust_training/210_unsafe_rust/02_dereferencing.rst index c290932b1..2a1724f99 100644 --- a/courses/comprehensive_rust_training/210_unsafe_rust/02_dereferencing.rst +++ b/courses/comprehensive_rust_training/210_unsafe_rust/02_dereferencing.rst @@ -47,7 +47,7 @@ it satisfies the safety requirements of the unsafe operations it is doing. In the case of pointer dereferences, this means that the pointers must -be `valid `__, +be :url:`valid `, i.e.: - The pointer must be non-null. diff --git a/courses/comprehensive_rust_training/210_unsafe_rust/04_unions.rst b/courses/comprehensive_rust_training/210_unsafe_rust/04_unions.rst index 7f0ee8785..b8952eaf3 100644 --- a/courses/comprehensive_rust_training/210_unsafe_rust/04_unions.rst +++ b/courses/comprehensive_rust_training/210_unsafe_rust/04_unions.rst @@ -33,9 +33,9 @@ They are occasionally needed for interacting with C library APIs. If you just want to reinterpret bytes as a different type, you probably want -`std::mem::transmute `__ +:url:`std::mem::transmute ` or a safe wrapper such as the -`zerocopy `__ crate. +:url:`zerocopy ` crate. .. raw:: html diff --git a/courses/comprehensive_rust_training/210_unsafe_rust/05_unsafe_functions.rst b/courses/comprehensive_rust_training/210_unsafe_rust/05_unsafe_functions.rst index cc066daa6..edccdc7a8 100644 --- a/courses/comprehensive_rust_training/210_unsafe_rust/05_unsafe_functions.rst +++ b/courses/comprehensive_rust_training/210_unsafe_rust/05_unsafe_functions.rst @@ -101,7 +101,7 @@ general any C function might have undefined behaviour under any arbitrary circumstances. The ``"C"`` in this example is the ABI; -`other ABIs are available too `__. +:url:`other ABIs are available too `. .. _writing-unsafe-functions-1: diff --git a/courses/comprehensive_rust_training/210_unsafe_rust/06_unsafe_traits.rst b/courses/comprehensive_rust_training/210_unsafe_rust/06_unsafe_traits.rst index 5af6dd949..afcacd5c4 100644 --- a/courses/comprehensive_rust_training/210_unsafe_rust/06_unsafe_traits.rst +++ b/courses/comprehensive_rust_training/210_unsafe_rust/06_unsafe_traits.rst @@ -11,7 +11,7 @@ implementation must guarantee particular conditions to avoid undefined behaviour. For example, the ``zerocopy`` crate has an unsafe trait that looks -`something like this `__: +:url:`something like this `: .. code:: rust,editable diff --git a/courses/comprehensive_rust_training/210_unsafe_rust/07_exercise.rst b/courses/comprehensive_rust_training/210_unsafe_rust/07_exercise.rst index 35a9153d3..8c00b46b7 100644 --- a/courses/comprehensive_rust_training/210_unsafe_rust/07_exercise.rst +++ b/courses/comprehensive_rust_training/210_unsafe_rust/07_exercise.rst @@ -13,12 +13,12 @@ directory. You will want to consult the manual pages: -- `opendir(3) `__ -- `readdir(3) `__ -- `closedir(3) `__ +- :url:`opendir(3) ` +- :url:`readdir(3) ` +- :url:`closedir(3) ` You will also want to browse the -`std::ffi `__ module. There you +:url:`std::ffi ` module. There you find a number of string types which you need for the exercise: .. list-table:: @@ -28,15 +28,15 @@ find a number of string types which you need for the exercise: - Encoding - Use - * - `str `__ and `String `__ + * - :url:`str ` and :url:`String ` - UTF-8 - Text processing in Rust - * - `CStr `__ and `CString `__ + * - :url:`CStr ` and :url:`CString ` - NUL-terminated - Communicating with C functions - * - `OsStr `__ and `OsString `__ + * - :url:`OsStr ` and :url:`OsString ` - OS-specific - Communicating with the OS @@ -51,12 +51,12 @@ You will convert between all these types: for "some unknown data", - ``&[u8]`` to ``&OsStr``: ``&OsStr`` is a step towards ``OsString``, use - `OsStrExt `__ + :url:`OsStrExt ` to create it, - ``&OsStr`` to ``OsString``: you need to clone the data in ``&OsStr`` to be able to return it and call ``readdir`` again. -The `Nomicon `__ also has a +The :url:`Nomicon ` also has a very useful chapter about FFI. Copy the code below to https://play.rust-lang.org/ and fill in the From 2aece63a147d97130fd724b0cd5411ea501cf648 Mon Sep 17 00:00:00 2001 From: Michael Frank <55284511+frank-at-adacore@users.noreply.github.com> Date: Tue, 11 Feb 2025 15:04:59 -0500 Subject: [PATCH 4/4] Style issues with beamer_filter --- pandoc/beamer_filter.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pandoc/beamer_filter.py b/pandoc/beamer_filter.py index 1c15c7d53..b6adc3188 100755 --- a/pandoc/beamer_filter.py +++ b/pandoc/beamer_filter.py @@ -799,13 +799,13 @@ def format_url(literal_text): # href if literal_text.endswith(">"): - first = literal_text.rfind("<") - if first > 0: - url = literal_text[first+1:len(literal_text)-1] - text = literal_text[0:first-1].strip() - if len(text) > 0: - text = latex_escape(text) - return latex_inline(text + " (\\url{" + url + "})") + first = literal_text.rfind("<") + if first > 0: + url = literal_text[first + 1 : len(literal_text) - 1] + text = literal_text[0 : first - 1].strip() + if len(text) > 0: + text = latex_escape(text) + return latex_inline(text + " (\\url{" + url + "})") # anything else return latex_inline("\\url{" + literal_text + "}")