MadCap has a blog post about adding a copy button to code blocks, found here.
Here's what I had to do to get it working:
Step 1: Download the clipboad javascript and put it in your Resources/Scripts folder:
https://github.com/zenorocha/clipboard.js/archive/master.zip
Step 2: Add this to the <head> section:
<script src="../../../Resources/Scripts/clipboard.min.js"></script>
Step 3: Before the final closing body tag (</body>), add this:
<script>new ClipboardJS('.cbtn');</script>
Note: I named the button is named cbtn.
Step 4: Enclose each code block like the following:
<div class="Code">
<p class="Codeblock" id="t01">Here's my code block text.</p>
<button class="cbtn" data-clipboard-action="copy" data-clipboard-target="#t01" MadCap:conditions="Default.ScreenOnly"> </button>
</div>
Note: The button class must match what you defined in step 3.
Note: The ID must be unique for each code block.
Note: I added the Default.ScreenOnly condition so that it doesn't appear in PDF/Word.
Step 5: Add the following to your CSS file:
div.Code
{
position: relative;
overflow-x: auto;
}
p.Codeblock + button
{
position: absolute;
bottom: 0;
right: 0;
width: 26px;
height: 26px;
margin-bottom: 6pt;
background: url(/url/to/image/content-copy.png)
}
Note: I use an image for the button, defined in the CSS. If you don't want an image, you can just put the plain text "Copy" in the HTML in step 4.
Note: The positioning places the button at the bottom right corner of the div.
Tuesday, May 7, 2019
Tuesday, October 9, 2018
|
|
Are You a Man or a Bloke? |
I recently tested the Mad Quality Plugin for Flare, which is a rule-checking application that uses various rule sets to check your text (kind of like the grammar checker in Word). The tool is a useful plug-in for Flare. Maybe I'll review it in another post.
One of the sample rule sets checks for British English (see the list below). Now, I really like finding all the differences between British and American English. I know what trainers are and sometimes I wear a jumper. But, I have no idea what some of the ones in this list mean.
Do you wrap your leftovers in aerofoil?
What do you do with a breakdown van? Is it really old and doesn't run well?
Courgette? Wasn't she that girl from Les Miserables?
Is a draughts game where you see whose lawn looks the best after not watering it for a month?
Are you insulted if someone asks you if you have a dummy for a baby?
Do you get green fingers after picking your nose?
I think there are some new diseases in England, like mangetout, aubergine, and diamante.
Is a windcheater a type of sailor?
Boob tube? Titbit? Um, maybe I don't want to know what those are.
Here's the complete list. How many do you know?
One of the sample rule sets checks for British English (see the list below). Now, I really like finding all the differences between British and American English. I know what trainers are and sometimes I wear a jumper. But, I have no idea what some of the ones in this list mean.
Do you wrap your leftovers in aerofoil?
What do you do with a breakdown van? Is it really old and doesn't run well?
Courgette? Wasn't she that girl from Les Miserables?
Is a draughts game where you see whose lawn looks the best after not watering it for a month?
Are you insulted if someone asks you if you have a dummy for a baby?
Do you get green fingers after picking your nose?
I think there are some new diseases in England, like mangetout, aubergine, and diamante.
Is a windcheater a type of sailor?
Boob tube? Titbit? Um, maybe I don't want to know what those are.
Here's the complete list. How many do you know?
- accommodation
- action replay
- aerofoil
- aeroplane
- agony aunt
- Allen key
- aluminium
- aniseed
- anticlockwise
- articulated lorry
- asymmetric bars
- aubergine
- baking tray
- bank holiday
- beetroot
- biscuit
- black economy
- blanket bath
- block of flats
- boiler suit
- bonnet
- boob tube
- boot
- bottom drawer
- bowls
- braces
- brawn the food
- breakdown van
- breeze block
- bridging loan
- bumbag
- candyfloss
- car park
- casualty
- catapult
- central reservation
- chemist
- chips
- cinema
- cling film
- common seal
- consumer durables
- cornflour
- cos
- cot
- cot death
- cotton bud
- cotton wool
- council estate
- courgette
- court card
- crash barrier
- crisps
- crocodile clip
- cross-ply
- crotchet
- current account
- danger money
- demister
- dialling tone
- diamante
- double cream
- draughts game
- drawing pin
- dressing gown
- drink-driving
- drinks cupboard
- drinks party
- driving licence
- dual carriageway
- dummy for a baby
- dust sheet
- dustbin
- engaged
- estate agent
- estate car
- ex-directory
- faith school
- financial year
- fire brigade
- first floor
- fish finger
- fitted carpet
- flannel
- flat
- flexitime
- flick knife
- flyover
- football
- footway
- fringe
- full stop
- garden
- gearing
- gear lever
- goods train
- greaseproof paper
- green fingers
- grill
- ground floor
- groundsman
- hairslide
- hatstand
- hen night
- hire purchase
- hoarding
- hob
- holdall
- holiday
- holidaymaker
- homely
- hosepipe
- in hospital
- hot flush
- housing estate
- hundreds and thousands
- ice lolly
- icing sugar
- indicator
- inside leg
- jelly babies
- Joe Bloggs
- Joe Public
- jumble sale
- jump lead
- jumper
- junior school
- kennel
- ladybird
- a lettuce
- level crossing
- lift
- lolly
- lollipop lady
- loose cover
- lorry
- loudhailer
- low loader
- lucky dip
- luggage van
- maize
- mangetout
- market garden
- marshalling yard
- maths
- metalled road
- milometer
- minim
- mobile phone
- monkey tricks
- motorway
- mum
- mummy
- nappy
- needlecord
- newsreader
- noughts and crosses
- number plate
- off-licence
- opencast mining
- ordinary share
- oven glove
- paddling pool
- paracetamol
- parting in hair
- patience
- pavement
- pay packet
- pedestrian crossing
- peg
- pelmet
- petrol
- physiotherapy
- pinafore dress
- plain chocolate
- plain flour
- polo neck
- positive discrimination
- postal vote
- postbox
- postcode
- potato crisp
- power point
- pram
- press stud
- press-up
- private soldier
- public school
- public transport
- punchbag
- pushchair
- pylon
- quantity surveyor
- quaver
- queue
- racing car
- railway
- real tennis
- recorded delivery
- registration plate
- remould
- reverse the charges
- reversing lights
- right-angled triangle
- ring road
- roundabout
- rowing boat
- sailing boat
- saloon
- sandpit
- sandwich cake
- sanitary towel
- self-raising flour
- semibreve
- semitone
- share option
- shopping trolley
- show house
- home
- silencer
- silverside
- skeleton in the cupboard
- skimmed milk
- skipping rope
- skirting board
- sledge
- sleeper
- sleeping partner
- slowcoach
- snakes and ladders
- solicitor
- soya
- soya bean
- splashback
- spring onion
- stag night
- Stanley knife
- starter
- state school
- storm in a teacup
- surtitle
- swede
- sweet
- takeaway
- taxi rank
- tea towel
- terrace house
- tick
- ticket tout
- timber
- titbit
- toffee apple
- touch wood
- trade union
- trading estate
- trainers
- transport cafe
- trolley
- twelve-bore
- underground
- vacuum flask
- verge
- vest
- veterinary surgeon
- wagon
- waistcoat
- walking frame
- wardrobe
- water ice
- weatherboard
- white coffee
- white spirit
- wholemeal bread
- windcheater
- windscreen
- worktop
- zebra crossing
- zed
- zip
Sunday, October 7, 2018
|
|
Make APIs Look Nice with Shins |
Anyone who is documenting or using APIs has probably come across a new, slick web interface for viewing APIs, like the one in this image:
So, what is this interface? And how do I get my APIs to look like it?
This interface is called Slate. It provides a 3-pane view, with a TOC, the API reference, and code samples. Unfortunately, I am running a Windows machine, and I couldn't get Slate to install.
Fortunately, there is a port of Slate, called Shins (Shins Is Not Slate). This port runs on Windows and uses NodeJS instead of Linux, Ruby, Bundler, etc.
Shins generates the Slate-like output with minimal effort from a Markdown file that contains your APIs. Since my R&D team creates a YAML file, I used widdershins to convert the YAML to Markdown.
Here's what you need to do:
- Create a folder on your computer called shins
- Clone the Shins repository to your local directory.
- Create a folder called widdershins in the shins directory.
- Clone the widdershins repo to your local directory.
- Copy your latest YAML file into the defs dir:
.\shins\widdershins\defs - Change directory to this one:
.\shins\widdershins - Run the following command:
node widdershins --search true .\defs\my-api.yaml -o my-api.md
Note: You can add a flag that lets you choose which languages to include in the output, such as:
--language_tabs 'javascript:JavaScript' 'shell:Shell' - Change directory to this one:
.\shins - Run the following command:
node .\shins.js --logo company-logo.png .\widdershins\my-api.md - The index.html file in that directory is created with the Slate/Shins output.
Monday, April 30, 2018
|
|
Word Macro: Set all Columns to the Same Width in Every Table |
Use the Word macro code below to set every column in every table to the width of the corresponding column in the reference table.
Sub fixColumnWidth()
'
' fixColumnWidth Macro
'
'
Dim refTable As Word.Table
Dim curTable As Word.Table
Dim i As Long
Dim col As Long
Set refTable = ActiveDocument.Tables(7) 'set this to whatever table is the reference table
For i = 2 To ActiveDocument.Tables.Count ' set the start value. Sometimes you want to skip the 1st table (such as Revision History)
Set curTable = ActiveDocument.Tables(i)
For col = 1 To refTable.Columns.Count
curTable.Columns(col).Width = refTable.Columns(col).Width
Next col
Next
End Sub
[Source: Microsoft Community]
Monday, April 9, 2018
|
|
Flare: Thinking Outside the Box |
If you have large figures, you can create a style that is larger than your normal margins by using a negative left margin. For example:
p.wideImage
{
margin-left: -35pt;
}
[Source: MadCap Forum]
p.wideImage
{
margin-left: -35pt;
}
[Source: MadCap Forum]
Subscribe to:
Posts (Atom)
