如何防止sphinx将url作为超链接?

时间:2012-12-04 03:14:15

标签: python-sphinx restructuredtext

在我的文档中,我偶尔会使用“垃圾”网址作为示例,并且不希望它们成为无处的超链接。是否有任何语法使这些网址不是超链接?

2 个答案:

答案 0 :(得分:16)

有三种方法可以格式化这些URL,使它们不是超链接。第一种方法是将样本URL与其他代码样本一样处理,并将它们放在反引号中,如下所示:

open ``http://www.example.com`` in a web browser

第二个是使用Sphinx :samp:角色,如下所示:

open :samp:`http://www.example.com` in a web browser

:samp:角色可让您强调可变部分。因此,例如,您可以指示用户选择的端口号,如下所示:

open :samp:`http://www.example.com:{port}` in a web browser

并且 port 这个词会突出显示,并且省略了大括号。

最后一个选项是使用反斜杠前缀示例URL,如下所示:

open \http://www.example.com in a web browser

网址将显示为普通文字,不是链接或具有任何特殊格式。

答案 1 :(得分:0)

除了@ddbeck回答,要转义电子邮件地址,请在@前面添加斜杠。

 <Record>
<LastName>REDACTED</LastName>
<FirstName>REDACTED</FirstName>
<DOB>REDACTED</DOB>
<Rapsheet>
  <Header>
    <DateOfBirth>REDACTED</DateOfBirth>
    <SID>REDACTED</SID>
    <Summary>
      <DateOfLastArrest>
        10/01/2012
      </DateOfLastArrest>
      <AgeOfOffender>21</AgeOfOffender>
      <FailuresToAppear>0</FailuresToAppear>
      <ViolationOfCourtOrdersOrConditions>
        0
      </ViolationOfCourtOrdersOrConditions>
      <FelonyArrestsConvictions>
        0/0
      </FelonyArrestsConvictions>
      <MisdemeanorArrestsConvictions>
        0/0
      </MisdemeanorArrestsConvictions>
      <UnknownOffenseLevelArrestsConvictions>
        1/0
      </UnknownOffenseLevelArrestsConvictions>
      <AssaultOnOfficerCharges>
        0
      </AssaultOnOfficerCharges>
      <DeadlyWeaponRelatedCharges>
        0
      </DeadlyWeaponRelatedCharges>
      <EscapeCharges>
        0
      </EscapeCharges>
      <ViolationOfProbationParoleCharges>
        0/0
      </ViolationOfProbationParoleCharges>
    </Summary>
  </Header>
  <Title>VERMONT CRIMINAL HISTORY</Title>
  <Identification>
    <VermontStateID>REDACTED</VermontStateID>
    <DateOfBirth>REDACTED</DateOfBirth>
    <PlaceOfBirthCity></PlaceOfBirthCity>
    <PlaceOfBirthStateOrCountry></PlaceOfBirthStateOrCountry>
    <Sex>F</Sex>
    <Race>W</Race>
    <Ethnicity>
    </Ethnicity>
    <USCitizen></USCitizen>
    <Height>503</Height>
    <Weight>180</Weight>
    <EyeColor>GRN</EyeColor>
    <HairColor>BLN</HairColor>
    <ScarsMarksTattoos>
      <SMTCode>TATTOO</SMTCode>
      <SMTDescription>ARABIC TATOO ON ARM</SMTDescription>
    </ScarsMarksTattoos>
    <ScarsMarksTattoos>
      <SMTCode>TATTOO</SMTCode>
      <SMTDescription>NOSE RING LIP RINGS</SMTDescription>
    </ScarsMarksTattoos>
    <PrintsNCIC></PrintsNCIC>
    <HenryUp></HenryUp>
    <HenryLow></HenryLow>
    <PhotoAvailable></PhotoAvailable>
    <Address>
      <Street>REDACTED</Street>
      <City>WINOOSKI</City>
      <State>VT</State>
      <Zip>05404</Zip>
    </Address>
  </Identification>
  <CriminalHistory>
    <Cycle>
      <CycleNumber>1</CycleNumber>
      <TrackingNumber>1709462</TrackingNumber>
        <Arrest>
          <DateOfArrest>10/01/2012 </DateOfArrest>
          <ArrestAgency>WINOOSKI PD VT0040400</ArrestAgency>
          <ArrestAgencyCaseNumber>12WS04470</ArrestAgencyCaseNumber>
          <Fingerprint>NO</Fingerprint>
          <Charge>
            <ChargeNumber>01</ChargeNumber>
            <ChargeDescription></ChargeDescription>
            <Statute></Statute>
            <Severity></Severity>
          </Charge>
        </Arrest>
        <Arraignment>
          <ArraignmentDate>04/18/2014</ArraignmentDate>
          <ArraignmentAgency>CHITTENDEN CO. DISTRICT COURT</ArraignmentAgency>
          <DocketNumber>REDACTED</DocketNumber>
          <Charge>
            <ChargeNumber>01</ChargeNumber>
            <ChargeDescription>ASSAULT-AGG DOMESTIC-1ST DEG WITH WEAPON</ChargeDescription>
            <Statute>13V1043A2</Statute>
            <Severity>FELONY</Severity>
          </Charge>
        </Arraignment>
        <CourtDisposition>
            <ChargeNumber>01</ChargeNumber>
            <Convicted>NO</Convicted>
            <Felony>NO</Felony>
            <ChargeDescription>ASSAULT-AGG DOMESTIC-1ST DEG WITH WEAPON</ChargeDescription>
            <Statute>13V1043A2</Statute>
            <Disposition>
              06/09/2014 CASE DISMISSED
            </Disposition>
        </CourtDisposition>
    </Cycle>
    <Cycle>
      <CycleNumber>2</CycleNumber>
      <TrackingNumber>1685833</TrackingNumber>
        <Arrest>
          <DateOfArrest>09/30/2012 </DateOfArrest>
          <ArrestAgency>WINOOSKI PD VT0040400</ArrestAgency>
          <ArrestAgencyCaseNumber>12WS004770</ArrestAgencyCaseNumber>
          <Fingerprint>NO</Fingerprint>
        </Arrest>
        <Arraignment>
          <ArraignmentDate>10/01/2012</ArraignmentDate>
          <ArraignmentAgency>CHITTENDEN CO. DISTRICT COURT</ArraignmentAgency>
          <DocketNumber>REDACTED</DocketNumber>
          <Charge>
            <ChargeNumber>01</ChargeNumber>
            <ChargeDescription>ASSAULT-AGG DOMESTIC-1ST DEG WITH WEAPON</ChargeDescription>
            <Statute>13V1043A2</Statute>
            <Severity>FELONY</Severity>
          </Charge>
        </Arraignment>
        <CourtDisposition>
            <ChargeNumber>01</ChargeNumber>
            <Convicted>NO</Convicted>
            <Felony>NO</Felony>
            <ChargeDescription>ASSAULT-AGG DOMESTIC-1ST DEG WITH WEAPON</ChargeDescription>
            <Statute>13V1043A2</Statute>
            <Disposition>
              12/02/2013 CASE DISMISSED
            </Disposition>
        </CourtDisposition>
    </Cycle>
  </CriminalHistory>
</Rapsheet>